[svn-commits] russell: branch group/res_config_ldap r39401 - in /team/group/res_config_ldap...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Aug 8 13:00:16 MST 2006


Author: russell
Date: Tue Aug  8 15:00:15 2006
New Revision: 39401

URL: http://svn.digium.com/view/asterisk?rev=39401&view=rev
Log:
- add res_config_ldap with new fixes to be current with changes in trunk
- make necessary build system changes

Added:
    team/group/res_config_ldap/configs/res_ldap.conf.sample   (with props)
    team/group/res_config_ldap/res/res_config_ldap.c   (with props)
Modified:
    team/group/res_config_ldap/build_tools/menuselect-deps.in
    team/group/res_config_ldap/configure
    team/group/res_config_ldap/configure.ac
    team/group/res_config_ldap/include/asterisk/autoconfig.h.in
    team/group/res_config_ldap/makeopts.in

Modified: team/group/res_config_ldap/build_tools/menuselect-deps.in
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/build_tools/menuselect-deps.in?rev=39401&r1=39400&r2=39401&view=diff
==============================================================================
--- team/group/res_config_ldap/build_tools/menuselect-deps.in (original)
+++ team/group/res_config_ldap/build_tools/menuselect-deps.in Tue Aug  8 15:00:15 2006
@@ -8,6 +8,7 @@
 IMAP_TK=@PBX_IMAP_TK@
 IXJUSER=@PBX_IXJUSER@
 KDE=@PBX_KDE@
+LDAP=@PBX_LDAP@
 NBS=@PBX_NBS@
 NETSNMP=@PBX_NETSNMP@
 NEWT=@PBX_NEWT@

Added: team/group/res_config_ldap/configs/res_ldap.conf.sample
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/configs/res_ldap.conf.sample?rev=39401&view=auto
==============================================================================
--- team/group/res_config_ldap/configs/res_ldap.conf.sample (added)
+++ team/group/res_config_ldap/configs/res_ldap.conf.sample Tue Aug  8 15:00:15 2006
@@ -1,0 +1,134 @@
+; Sample Asterisk config file for res_config_ldap
+; in extconfig.conf you can use it like this:
+; sipusers => ldap,"dc=myDomain,dc=myDomainExt",sip
+; sippeers => ldap,"dc=myDomain,dc=myDomainExt",sip
+; extensions => ldap,"dc=myDomain,dc=myDomainExt",extensions
+; sip.conf => ldap,"dc=myDomain,dc=myDomainExt",config
+
+
+[_general]
+;dbhost=192.168.1.1,ldap.mydomain.com	; LDAP host(s)
+;dbbasedn=MyRootDN	; Base DN
+;dbpass=MyPassword	; Bind password
+;dbuser=MyDN		; Bind DN
+
+; Configuration Table
+[config]
+; Attributes mapping (asterisk variable name => ldap attribute name)
+attribute = filename => oxyPBXConfigFilename
+attribute = category => oxyPBXConfigCategory
+attribute = variable_name => oxyPBXConfigVariableName
+attribute = variable_value => oxyPBXConfigVariableValue
+attribute = cat_metric => oxyPBXConfigCategoryMetric
+attribute = commented => oxyPBXConfigCommented
+
+; addtional filter
+additionalFilter=(objectClass=oxyPBXConfig)
+
+; Extensions Table
+[extensions]
+attribute = context  =>  oxyPBXExtensionContext
+attribute = exten  =>  oxyPBXExtensionExten
+attribute = priority => oxyPBXExtensionPriority
+attribute = app => oxyPBXExtensionApplication
+attribute = appdata => oxyPBXExtensionApplicationData
+additionalFilter=(objectClass=oxyPBXExtension)
+
+; Sip Users Table
+[sip]
+attribute = name => uid
+attribute = amaflags => oxyPBXAccountAMAFlags
+attribute = callgroup => oxyPBXAccountCallGroup
+attribute = callerid => oxyPBXAccountCallerID
+attribute = canreinvite => oxyPBXAccountCanReinvite
+attribute = context => oxyPBXAccountContext
+attribute = dtmfmode => oxyPBXAccountDTMFMode
+attribute = fromuser => oxyPBXAccountFromUser
+attribute = fromdomain => oxyPBXAccountFromDomain
+attribute = fullcontact => oxyPBXAccountFullContact
+attribute = fullcontact => gecos
+attribute = host => oxyPBXAccountHost
+attribute = insecure => oxyPBXAccountInsecure
+attribute = mailbox => oxyPBXAccountMailbox
+attribute = md5secret => realmedPassword
+attribute = nat => oxyPBXAccountNAT
+attribute = deny => oxyPBXAccountDeny
+attribute = permit => oxyPBXAccountPermit
+attribute = pickupgroup => oxyPBXAccountPickupGroup
+attribute = port => oxyPBXAccountPort
+attribute = qualify => oxyPBXAccountQualify
+attribute = restrictcid => oxyPBXAccountRestrictCID
+attribute = rtptimeout => oxyPBXAccountRTPTimeout
+attribute = rtpholdtimeout => oxyPBXAccountRTPHoldTimeout
+attribute = type => oxyPBXAccountType
+attribute = disallow => oxyPBXAccountDisallowedCodec
+attribute = allow => oxyPBXAccountAllowedCodec
+attribute = MusicOnHold => oxyPBXAccountMusicOnHold
+attribute = regseconds => oxyPBXAccountExpirationTimestamp
+attribute = regcontext => oxyPBXAccountRegistrationContext
+attribute = regexten => oxyPBXAccountRegistrationExten
+attribute = CanCallForward => oxyPBXAccountCanCallForward
+additionalFilter=(objectClass=oxyPBXAccountSIP)
+
+; IAX Users Table
+[iax]
+attribute = amaflags => oxyPBXAccountAMAFlags
+attribute = callerid => oxyPBXAccountCallerID
+attribute = context => oxyPBXAccountContext
+attribute = fullcontact => oxyPBXAccountFullContact
+attribute = fullcontact => gecos
+attribute = host => oxyPBXAccountHost
+attribute = mailbox => oxyPBXAccountMailbox
+attribute = md5secret => realmedPassword
+attribute = deny => oxyPBXAccountDeny
+attribute = permit => oxyPBXAccountPermit
+attribute = port => oxyPBXAccountPort
+attribute = qualify => oxyPBXAccountQualify
+attribute = type => oxyPBXAccountType
+attribute = disallow => oxyPBXAccountDisallowedCodec
+attribute = allow => oxyPBXAccountAllowedCodec
+attribute = regseconds => oxyPBXAccountExpirationTimestamp
+attribute = regcontext => oxyPBXAccountRegistrationContext
+attribute = regexten => oxyPBXAccountRegistrationExten
+attribute = notransfer => oxyPBXAccountNoTransfer
+additionalFilter=(objectClass=oxyPBXAccountIAX)
+
+; A Test Family
+[testfamily]
+attribute = MyUSERID => uid
+additionalFilter=(objectClass=*)
+
+[accounts]
+attribute = amaflags => oxyPBXAccountAMAFlags
+attribute = callgroup => oxyPBXAccountCallGroup
+attribute = callerid => oxyPBXAccountCallerID
+attribute = canreinvite => oxyPBXAccountCanReinvite
+attribute = context => oxyPBXAccountContext
+attribute = dtmfmode => oxyPBXAccountDTMFMode
+attribute = fromuser => oxyPBXAccountFromUser
+attribute = fromdomain => oxyPBXAccountFromDomain
+attribute = fullcontact => oxyPBXAccountFullContact
+attribute = fullcontact => gecos
+attribute = host => oxyPBXAccountHost
+attribute = insecure => oxyPBXAccountInsecure
+attribute = mailbox => oxyPBXAccountMailbox
+attribute = md5secret => realmedPassword
+attribute = nat => oxyPBXAccountNAT
+attribute = deny => oxyPBXAccountDeny
+attribute = permit => oxyPBXAccountPermit
+attribute = pickupgroup => oxyPBXAccountPickupGroup
+attribute = port => oxyPBXAccountPort
+attribute = qualify => oxyPBXAccountQualify
+attribute = restrictcid => oxyPBXAccountRestrictCID
+attribute = rtptimeout => oxyPBXAccountRTPTimeout
+attribute = rtpholdtimeout => oxyPBXAccountRTPHoldTimeout
+attribute = type => oxyPBXAccountType
+attribute = disallow => oxyPBXAccountDisallowedCodec
+attribute = allow => oxyPBXAccountAllowedCodec
+attribute = MusicOnHold => oxyPBXAccountMusicOnHold
+attribute = regseconds => oxyPBXAccountExpirationTimestamp
+attribute = regcontext => oxyPBXAccountRegistrationContext
+attribute = regexten => oxyPBXAccountRegistrationExten
+attribute = CanCallForward => oxyPBXAccountCanCallForward
+additionalFilter=(objectClass=oxyPBXAccount)
+

Propchange: team/group/res_config_ldap/configs/res_ldap.conf.sample
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/group/res_config_ldap/configs/res_ldap.conf.sample
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/group/res_config_ldap/configs/res_ldap.conf.sample
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/group/res_config_ldap/configure
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/configure?rev=39401&r1=39400&r2=39401&view=diff
==============================================================================
--- team/group/res_config_ldap/configure (original)
+++ team/group/res_config_ldap/configure Tue Aug  8 15:00:15 2006
@@ -708,6 +708,9 @@
 KDE_LIB
 KDE_INCLUDE
 PBX_KDE
+LDAP_LIB
+LDAP_INCLUDE
+PBX_LDAP
 NBS_LIB
 NBS_INCLUDE
 PBX_NBS
@@ -1401,6 +1404,7 @@
   --with-iksemel=PATH     use Iksemel Jabber Library files in PATH
   --with-imap=PATH        use UW IMAP Toolkit files in PATH
   --with-kde=PATH         use KDE files in PATH
+  --with-ldap=PATH        use OpenLDAP files in PATH
   --with-nbs=PATH         use Network Broadcast Sound files in PATH
   --with-ncurses=PATH     use ncurses files in PATH
   --with-netsnmp=PATH     use Net-SNMP files in PATH
@@ -5717,6 +5721,33 @@
 fi
 
 PBX_KDE=0
+
+
+
+
+
+LDAP_DESCRIP="OpenLDAP"
+LDAP_OPTION="ldap"
+
+# Check whether --with-ldap was given.
+if test "${with_ldap+set}" = set; then
+  withval=$with_ldap;
+case ${withval} in
+     n|no)
+     USE_LDAP=no
+     ;;
+     y|ye|yes)
+     LDAP_MANDATORY="yes"
+     ;;
+     *)
+     LDAP_DIR="${withval}"
+     LDAP_MANDATORY="yes"
+     ;;
+esac
+
+fi
+
+PBX_LDAP=0
 
 
 
@@ -16804,6 +16835,458 @@
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+if test "${USE_LDAP}" != "no"; then
+   pbxlibdir=""
+   if test "x${LDAP_DIR}" != "x"; then
+      if test -d ${LDAP_DIR}/lib; then
+      	 pbxlibdir="-L${LDAP_DIR}/lib"
+      else
+      	 pbxlibdir="-L${LDAP_DIR}"
+      fi
+   fi
+   { echo "$as_me:$LINENO: checking for ldap_first_attribute in -lldap" >&5
+echo $ECHO_N "checking for ldap_first_attribute in -lldap... $ECHO_C" >&6; }
+if test "${ac_cv_lib_ldap_ldap_first_attribute+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lldap ${pbxlibdir}  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ldap_first_attribute ();
+int
+main ()
+{
+return ldap_first_attribute ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ldap_ldap_first_attribute=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_ldap_ldap_first_attribute=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_ldap_ldap_first_attribute" >&5
+echo "${ECHO_T}$ac_cv_lib_ldap_ldap_first_attribute" >&6; }
+if test $ac_cv_lib_ldap_ldap_first_attribute = yes; then
+  AST_LDAP_FOUND=yes
+else
+  AST_LDAP_FOUND=no
+fi
+
+
+   if test "${AST_LDAP_FOUND}" = "yes"; then
+      LDAP_LIB="-lldap "
+      LDAP_HEADER_FOUND="1"
+      if test "x${LDAP_DIR}" != "x"; then
+         LDAP_LIB="${pbxlibdir} ${LDAP_LIB}"
+	 LDAP_INCLUDE="-I${LDAP_DIR}/include"
+	 if test "xldap.h" != "x" ; then
+	    as_ac_Header=`echo "ac_cv_header_${LDAP_DIR}/include/ldap.h" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for ${LDAP_DIR}/include/ldap.h" >&5
+echo $ECHO_N "checking for ${LDAP_DIR}/include/ldap.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking ${LDAP_DIR}/include/ldap.h usability" >&5
+echo $ECHO_N "checking ${LDAP_DIR}/include/ldap.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <${LDAP_DIR}/include/ldap.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking ${LDAP_DIR}/include/ldap.h presence" >&5
+echo $ECHO_N "checking ${LDAP_DIR}/include/ldap.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <${LDAP_DIR}/include/ldap.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${LDAP_DIR}/include/ldap.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ${LDAP_DIR}/include/ldap.h: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for ${LDAP_DIR}/include/ldap.h" >&5
+echo $ECHO_N "checking for ${LDAP_DIR}/include/ldap.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  LDAP_HEADER_FOUND=1
+else
+  LDAP_HEADER_FOUND=0
+fi
+
+
+	 fi
+      else
+	 if test "xldap.h" != "x" ; then
+            if test "${ac_cv_header_ldap_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for ldap.h" >&5
+echo $ECHO_N "checking for ldap.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_ldap_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_ldap_h" >&5
+echo "${ECHO_T}$ac_cv_header_ldap_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking ldap.h usability" >&5
+echo $ECHO_N "checking ldap.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <ldap.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking ldap.h presence" >&5
+echo $ECHO_N "checking ldap.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ldap.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: ldap.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ldap.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ldap.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ldap.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: ldap.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ldap.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ldap.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ldap.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ldap.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ldap.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ldap.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ldap.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ldap.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ldap.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ldap.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ldap.h: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for ldap.h" >&5
+echo $ECHO_N "checking for ldap.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_ldap_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_ldap_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_ldap_h" >&5
+echo "${ECHO_T}$ac_cv_header_ldap_h" >&6; }
+
+fi
+if test $ac_cv_header_ldap_h = yes; then
+  LDAP_HEADER_FOUND=1
+else
+  LDAP_HEADER_FOUND=0
+fi
+
+
+	 fi
+      fi
+      if test "x${LDAP_HEADER_FOUND}" = "x0" ; then
+         if test ! -z "${LDAP_MANDATORY}" ;
+         then
+            echo " ***"
+            echo " *** It appears that you do not have the ldap development package installed."
+            echo " *** Please install it to include ${LDAP_DESCRIP} support, or re-run configure"
+            echo " *** without explicitly specifying --with-${LDAP_OPTION}"
+            exit 1
+         fi
+         LDAP_LIB=""
+         LDAP_INCLUDE=""
+         PBX_LDAP=0
+      else
+         PBX_LDAP=1
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_LDAP 1
+_ACEOF
+
+      fi
+   elif test ! -z "${LDAP_MANDATORY}";
+   then
+      echo "***"
+      echo "*** The ${LDAP_DESCRIP} installation on this system appears to be broken."
+      echo "*** Either correct the installation, or run configure"
+      echo "*** without explicitly specifying --with-${LDAP_OPTION}"
+      exit 1
+   fi
+fi
 
 
 
@@ -28246,6 +28729,9 @@
 KDE_LIB!$KDE_LIB$ac_delim
 KDE_INCLUDE!$KDE_INCLUDE$ac_delim
 PBX_KDE!$PBX_KDE$ac_delim
+LDAP_LIB!$LDAP_LIB$ac_delim
+LDAP_INCLUDE!$LDAP_INCLUDE$ac_delim
+PBX_LDAP!$PBX_LDAP$ac_delim
 NBS_LIB!$NBS_LIB$ac_delim
 NBS_INCLUDE!$NBS_INCLUDE$ac_delim
 PBX_NBS!$PBX_NBS$ac_delim
@@ -28331,9 +28817,6 @@
 PG_CONFIG!$PG_CONFIG$ac_delim
 QTMOC!$QTMOC$ac_delim
 EDITLINE_LIB!$EDITLINE_LIB$ac_delim
-PBX_H323!$PBX_H323$ac_delim
-PBX_IXJUSER!$PBX_IXJUSER$ac_delim
-GTKCONFIG!$GTKCONFIG$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -28375,6 +28858,9 @@
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+PBX_H323!$PBX_H323$ac_delim
+PBX_IXJUSER!$PBX_IXJUSER$ac_delim
+GTKCONFIG!$GTKCONFIG$ac_delim
 PBX_GTK!$PBX_GTK$ac_delim
 GTK_INCLUDE!$GTK_INCLUDE$ac_delim
 GTK_LIB!$GTK_LIB$ac_delim
@@ -28384,7 +28870,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 7; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 10; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

Modified: team/group/res_config_ldap/configure.ac
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/configure.ac?rev=39401&r1=39400&r2=39401&view=diff
==============================================================================
--- team/group/res_config_ldap/configure.ac (original)
+++ team/group/res_config_ldap/configure.ac Tue Aug  8 15:00:15 2006
@@ -202,6 +202,7 @@
 AST_EXT_LIB_SETUP([IKSEMEL], [Iksemel Jabber Library], [iksemel])
 AST_EXT_LIB_SETUP([IMAP_TK], [UW IMAP Toolkit], [imap])
 AST_EXT_LIB_SETUP([KDE], [KDE], [kde])
+AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
 AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
 AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses])
 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
@@ -479,6 +480,8 @@
 fi
 
 AC_LANG_POP
+
+AST_EXT_LIB_CHECK([LDAP], [ldap], [ldap_first_attribute], [ldap.h])
 
 AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
 

Modified: team/group/res_config_ldap/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/include/asterisk/autoconfig.h.in?rev=39401&r1=39400&r2=39401&view=diff
==============================================================================
--- team/group/res_config_ldap/include/asterisk/autoconfig.h.in (original)
+++ team/group/res_config_ldap/include/asterisk/autoconfig.h.in Tue Aug  8 15:00:15 2006
@@ -132,6 +132,9 @@
 
 /* Define to 1 if you have the `isascii' function. */
 #undef HAVE_ISASCII
+
+/* Define to indicate the ${LDAP_DESCRIP} library */
+#undef HAVE_LDAP
 
 /* Define to 1 if you have the <libintl.h> header file. */
 #undef HAVE_LIBINTL_H

Modified: team/group/res_config_ldap/makeopts.in
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/makeopts.in?rev=39401&r1=39400&r2=39401&view=diff
==============================================================================
--- team/group/res_config_ldap/makeopts.in (original)
+++ team/group/res_config_ldap/makeopts.in Tue Aug  8 15:00:15 2006
@@ -71,6 +71,9 @@
 KDE_INCLUDE=@KDE_INCLUDE@
 KDE_LIB=@KDE_LIB@
 
+LDAP_INCLUDE=@LDAP_INCLUDE@
+LDAP_LIB=@LDAP_LIB@
+
 NBS_INCLUDE=@NBS_INCLUDE@
 NBS_LIB=@NBS_LIB@
 

Added: team/group/res_config_ldap/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/team/group/res_config_ldap/res/res_config_ldap.c?rev=39401&view=auto
==============================================================================
--- team/group/res_config_ldap/res/res_config_ldap.c (added)
+++ team/group/res_config_ldap/res/res_config_ldap.c Tue Aug  8 15:00:15 2006
@@ -1,0 +1,1161 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Copyright (C) 2005, Oxymium sarl
+ * 
+ * Manuel Guesdon <mguesdon at oxymium.net> - LDAP RealTime Driver Author/Adaptor
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ *
+ */
+
+/*! \file
+ *
+ * \brief ldap plugin for portable configuration engine (ARA)
+ *
+ * \author Mark Spencer <markster at digium.com>
+ * \author Manuel Guesdon
+ *
+ * \arg http://www.openldap.org
+ */
+
+/*** MODULEINFO
+	<depend>ldap</depend>
+ ***/
+
+#include "asterisk.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <ldap.h>
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/channel.h"
+#include "asterisk/logger.h"
+#include "asterisk/config.h"
+#include "asterisk/module.h"
+#include "asterisk/lock.h"
+#include "asterisk/options.h"
+#include "asterisk/cli.h"
+#include "asterisk/utils.h"
+#include "asterisk/strings.h"
+#include "asterisk/pbx.h"
+#include "asterisk/linkedlists.h"
+
+static char *res_config_ldap_desc = "LDAP RealTime Configuration Driver";
+AST_MUTEX_DEFINE_STATIC(ldap_lock);
+#define RES_CONFIG_LDAP_CONF "res_ldap.conf"
+static LDAP *ldapConn = NULL;
+static char dbhost[512] = "";
+static char dbuser[512] = "";
+static char dbpass[50] = "";
+static char dbbasedn[512] = "";
+static int dbport = 389;
+static time_t connect_time = 0;
+
+static int parse_config(void);
+static int ldap_reconnect(void);
+static int realtime_ldap_status(int fd, int argc, char **argv);
+
+LOCAL_USER_DECL;
+
+struct category_and_metric {
+	char *name;
+	int metric;
+	char *variable_name;
+	char *variable_value;
+};
+
+static char cli_realtime_ldap_status_usage[] =
+	"Usage: realtime ldap status\n"
+	"       Shows connection information for the LDAP RealTime driver\n";
+
+static struct ast_cli_entry cli_realtime_ldap_status = {
+	{ "realtime", "ldap", "status", NULL }, realtime_ldap_status,
+	"Shows connection information for the LDAP RealTime driver",
+	cli_realtime_ldap_status_usage, NULL
+};
+
+/*! \brief Table configuration */
+struct ldap_table_config {
+	char *table_name;			/*!< table name */
+	char *additional_filter;		/*!< additional filter        */
+	struct ast_variable *attributes;	/*!< attribute names conversion */
+	struct ldap_table_config *next;		/*!< next entry */
+};
+
+/*! \brief Should be locked before using it */
+static struct ldap_table_config *table_configs = NULL;
+static struct ldap_table_config *base_table_config = NULL;
+
+/*! \brief Create a new table_config */
+static struct ldap_table_config *table_config_new(const char *table_name)
+{
+	struct ldap_table_config *p = ast_calloc(1, sizeof(*p));
+	if (table_name)
+		p->table_name = strdup(table_name);
+	return p;
+}
+
+/*! \brief Find a table_config - Should be locked before using it */
+static struct ldap_table_config *table_config_for_table_name(const char *table_name)
+{
+	struct ldap_table_config *c = table_configs;
+	while (c) {
+		if (strcmp(c->table_name, table_name) == 0)
+			return c;
+		else
+			c = c->next;
+	}
+	return NULL;
+}
+
+/*! \brief add attribute to table config - Should be locked before using it */
+static void ldap_table_config_add_attribute(struct ldap_table_config *table_config,
+					    const char *attribute_string)
+{
+	if (attribute_string && *attribute_string) {
+		char *string = strdup(attribute_string);
+		char *start = string;
+		char *p = strstr(start, "=>");
+
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Add attribute: start: %s\n", start);
+
+		if (!p) {
+			ast_log(LOG_WARNING,
+					"Missing '=>' in attribute: %s in %s\n",
+					attribute_string, table_config->table_name);
+		} else {
+			char *value = p + 2;	//skip =>      
+			/* trim ! */
+			while (isspace(*start))
+				start++;
+			p--;
+			while (p >= start && isspace(*p)) {
+				*p = '\0';
+				p--;
+			}
+			while (isspace(*value))
+				value++;
+			p = value + strlen(value) - 1;
+			while (p >= value && isspace(*p)) {
+				*p = '\0';
+				p--;
+			}
+			if (ast_strlen_zero(start)) {
+				ast_log(LOG_WARNING,
+						"Empty variable name in attribute: %s in %s\n",
+						attribute_string, table_config->table_name);
+			} else if (ast_strlen_zero(value)) {
+				ast_log(LOG_WARNING,
+						"Empty ldap attribute name in attribute: %s in %s\n",
+						attribute_string, table_config->table_name);
+			} else {
+				struct ast_variable *var = ast_variable_new(start, value);
+				if (option_debug > 2)
+					ast_log(LOG_DEBUG, "Add attribute: VAR %s => %s\n",var->name,var->value);
+				if (table_config->attributes)
+					var->next = table_config->attributes;
+				table_config->attributes = var;
+				if (option_debug > 2)
+					ast_log(LOG_DEBUG, "Added attribute in %s: %s -> %s\n",
+						table_config->table_name, start, value);
+			}
+		}
+		free(string);
+	}
+}
+
+/*! \brief Free table_config */
+static void table_configs_free(void)
+{
+	struct ldap_table_config *c = table_configs;
+
+	while (c) {
+		struct ldap_table_config *next = c->next;
+		if (c->table_name)
+			free(c->table_name);
+		if (c->additional_filter)
+			free(c->additional_filter);
+		if (c->attributes) {
+			ast_variables_destroy(c->attributes);
+		}
+		free(c);
+		c = next;
+	}
+	table_configs = NULL;
+	base_table_config = NULL;
+}
+
+/*! \brief Convert variable name to ldap attribute name - Should be locked before using it */
+static const char *convert_attribute_name_to_ldap(struct ldap_table_config *table_config,
+						  const char *attribute_name)
+{
+	int i = 0;
+	for (i = 0; i < 2; i++) {
+		if (table_config) {
+			struct ast_variable *attribute = table_config->attributes;
+			while (attribute) {
+				if (strcasecmp(attribute_name, attribute->name) == 0)
+					return attribute->value;
+				else
+					attribute = attribute->next;
+			}
+		}
+		if (table_config == base_table_config)
+			break;
+		else
+			table_config = base_table_config;
+	}
+	return attribute_name;
+}
+
+/*! \brief Convert ldap attribute name to variable name - Should be locked before using it */
+static const char *convert_attribute_name_from_ldap(struct ldap_table_config *table_config,
+						    const char *attribute_name)
+{
+	int i = 0;
+
+	for (i = 0; i < 2; i++) {
+		if (table_config) {
+			struct ast_variable *attribute = table_config->attributes;
+
+			while (attribute) {
+				if (strcasecmp(attribute_name, attribute->value) == 0)
+					return attribute->name;
+				else
+					attribute = attribute->next;
+			}
+		}
+		if (table_config == base_table_config)
+			break;
+		else
+			table_config = base_table_config;
+	}
+	return attribute_name;
+}
+
+/*! \brief Find variable by name */
+static struct ast_variable *variable_named(struct ast_variable *var,
+					   const char *name)
+{
+	while (var) {
+		if (strcasecmp(name, var->name) == 0)
+			return var;
+		else
+			var = var->next;
+	}
+	return NULL;
+}
+
+/*! \brief Get variables from ldap entry attributes - Should be locked before using it */
+static struct ast_variable *realtime_ldap_entry_to_var(struct ldap_table_config *table_config,
+						       LDAPMessage *ldap_entry)
+{
+	BerElement *ber = NULL;
+	struct ast_variable *var = NULL;
+	struct ast_variable *prev = NULL;
+
+	char *ldap_attribute_name = ldap_first_attribute(ldapConn, ldap_entry, &ber);
+
+	while (ldap_attribute_name) {
+		const char *attribute_name =
+			convert_attribute_name_from_ldap(table_config,ldap_attribute_name);
+		int is_realmed_password_attribute = strcasecmp(attribute_name, "md5secret") == 0;
+		char **values = NULL;
+
+		values = ldap_get_values(ldapConn, ldap_entry, ldap_attribute_name);
+		if (values) {
+			char **v = values;
+
+			while (*v) {
+				char *value = *v;
+				if (option_debug > 1)
+					ast_log(LOG_DEBUG, "attribute_name: %s value: %s\n", attribute_name, value);
+				if (is_realmed_password_attribute) {
+					if (strncasecmp(value, "{md5}", 5) == 0)
+						value += 5;
+					else
+						value = NULL;
+					if (option_debug > 1)
+						ast_log(LOG_DEBUG, "md5: %s\n", value);
+				}
+				if (value) {
+					if (prev) {
+						prev->next = ast_variable_new(attribute_name, value);
+						if (prev->next) 
+							prev = prev->next;
+					} else {
+						prev = var = ast_variable_new(attribute_name, value);
+					}
+				}
+				v++;
+			}
+			ldap_value_free(values);
+		}
+		ldap_attribute_name = ldap_next_attribute(ldapConn, ldap_entry, ber);
+	}
+	ber_free(ber, 0);
+
+	return var;
+}
+
+static int is_ldap_connect_error(int err)
+{
+	return (err == LDAP_SERVER_DOWN
+			|| err == LDAP_TIMEOUT || err == LDAP_CONNECT_ERROR);
+}
+
+/*! \brief LGet LDAP entry by dn and return attributes as variables  - Should be locked before using it */
+static struct ast_variable *ldap_loadentry(struct ldap_table_config *table_config,
+					   const char *dn)
+{
+	if (!table_config) {
+		ast_log(LOG_ERROR, "No table config\n");
+		return NULL;
+	} else {
+		struct ast_variable *var = NULL;
+		int result = -1;
+		LDAPMessage *ldap_result = NULL;
+		int tries = 0;
+
+		if (option_debug > 1)
+			ast_log(LOG_DEBUG, "ldap_loadentry dn=%s\n", dn);
+
+		do {
+			result = ldap_search_s(ldapConn, dn, LDAP_SCOPE_BASE,
+					   "(objectclass=*)", NULL, 0, &ldap_result);
+			if (result < 0 && is_ldap_connect_error(result)) {
+				ast_log(LOG_WARNING,
+					"Failed to query database. Try %d/3\n",
+					tries + 1);
+				tries++;
+				if (tries < 3) {
+					usleep(500000L * tries);
+					if (ldapConn) {
+						ldap_unbind_s(ldapConn);
+						ldapConn = NULL;
+					}
+					if (!ldap_reconnect())
+						break;
+				}
+			}
+		} while (result < 0 && tries < 3 && is_ldap_connect_error(result));
+
+		if (result < 0) {
+			ast_log(LOG_WARNING,
+					"Failed to query database. Check debug for more info.\n");
+			if (option_debug > 1) {
+				ast_log(LOG_DEBUG, "dn=%s\n", dn);
+				ast_log(LOG_DEBUG, "Query Failed because: %s\n",
+					ldap_err2string(result));
+			}
+			ast_mutex_unlock(&ldap_lock);
+			return NULL;
+		} else {
+			int num_entry = 0;
+			if ((num_entry = ldap_count_entries(ldapConn, ldap_result)) > 0) {
+				LDAPMessage *ldap_entry = NULL;
+				if (option_debug)
+					ast_log(LOG_DEBUG, "num_entry: %d\n", num_entry);
+
+				ldap_entry = ldap_first_entry(ldapConn, ldap_result);
+				var = realtime_ldap_entry_to_var(table_config, ldap_entry);
+				if (num_entry > 1)
+					ast_log(LOG_WARNING, "More than one entry for dn=%s. Take only 1st one\n", dn);
+			} else {
+				ast_log(LOG_WARNING, "Could not find any entry dn=%s.\n", dn);
+			}
+		}
+		ldap_msgfree(ldap_result);
+
+		return var;
+	}
+}
+
+/*! \brief caller should free returned pointer */
+static char *substituted(struct ast_channel *channel, const char *string)
+{
+#define MAXRESULT	2048
+	char *ret_string = NULL;
+
+	if (!ast_strlen_zero(string)) {
+		ret_string = ast_calloc(1, MAXRESULT);
+		pbx_substitute_variables_helper(channel, string, ret_string, MAXRESULT - 1);
+	}
+	if (option_debug > 1)
+		ast_log(LOG_DEBUG, "substituted: string: '%s' => '%s' \n",
+			string, ret_string);

[... 774 lines stripped ...]


More information about the svn-commits mailing list