[svn-commits] anthonyl: branch anthonyl/5768-ldap-redux r48094 - in /team/anthonyl/5768-lda...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Nov 28 10:53:39 MST 2006


Author: anthonyl
Date: Tue Nov 28 11:53:39 2006
New Revision: 48094

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48094
Log:
starting to reorganize and impliment sasl auth

Modified:
    team/anthonyl/5768-ldap-redux/include/asterisk/lock.h
    team/anthonyl/5768-ldap-redux/res/res_config_ldap.c

Modified: team/anthonyl/5768-ldap-redux/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/5768-ldap-redux/include/asterisk/lock.h?view=diff&rev=48094&r1=48093&r2=48094
==============================================================================
--- team/anthonyl/5768-ldap-redux/include/asterisk/lock.h (original)
+++ team/anthonyl/5768-ldap-redux/include/asterisk/lock.h Tue Nov 28 11:53:39 2006
@@ -49,7 +49,7 @@
 #include <netdb.h>
 #include <time.h>
 #include <sys/param.h>
-
+#include <pthread.h>
 #include "asterisk/logger.h"
 
 /* internal macro to profile mutexes. Only computes the delay on
@@ -80,8 +80,8 @@
 
 /* Asterisk REQUIRES recursive (not error checking) mutexes
    and will not run without them. */
-#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
-#define PTHREAD_MUTEX_INIT_VALUE	PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
+#define PTHREAD_MUTEX_INIT_VALUE	PTHREAD_RECURSIVE_MUTEX_INITIALIZER
 #define AST_MUTEX_KIND			PTHREAD_MUTEX_RECURSIVE_NP
 #else
 #define PTHREAD_MUTEX_INIT_VALUE	PTHREAD_MUTEX_INITIALIZER

Modified: team/anthonyl/5768-ldap-redux/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/5768-ldap-redux/res/res_config_ldap.c?view=diff&rev=48094&r1=48093&r2=48094
==============================================================================
--- team/anthonyl/5768-ldap-redux/res/res_config_ldap.c (original)
+++ team/anthonyl/5768-ldap-redux/res/res_config_ldap.c Tue Nov 28 11:53:39 2006
@@ -62,6 +62,18 @@
 
 /* note to me: group these into a structure */
 AST_MUTEX_DEFINE_STATIC(ldap_lock);
+
+struct ldap_connection {
+	LDAP *ldapConn;
+	char dbhost[512];
+	char dbuser[512]; /* this should really be a cn with authority */
+	char dbpass[50];
+	char dbbasedb[50];
+	int dbport;
+	int ldapversion;  /* new in my branch ldap version required to connect */
+	int ldapauthtype; /* simple or sasl authencation */
+	time_t connect_time;
+};
 
 static LDAP *ldapConn = NULL;
 static char dbhost[512] = "";
@@ -1112,7 +1124,7 @@
 static int ldap_reconnect(void)
 {
 	/* mutex lock should have been locked before calling this function. */
-	int bind_result = 0;
+	int res = 0;
 
 	if (ldapConn) {
 		if (option_debug > 1)
@@ -1130,31 +1142,37 @@
 		return 0;
 	} 
 
-	ldap_set_option(ldapConn, LDAP_OPT_PROTOCOL_VERSION, &ldapversion);
+	res = ldap_set_option(ldapConn, LDAP_OPT_PROTOCOL_VERSION, &ldapversion);
 	
+	if (res != LDAP_OPT_SUCCESS) {
+		ast_log(LOG_ERROR,"Failed to set the ldap protocol version\n");
+		return 0;
+	}
 	
 	if (dbuser && *dbuser) {
 		if (ldapauthtype == LDAP_AUTH_SIMPLE) {
 			bind_result = ldap_simple_bind_s(ldapConn, dbUser, dbPass);
 		else {
 			/* connect via sasl */
+		
 		}
 	} else {
 		
 		if (ldapauthtype == LDAP_AUTH_SIMPLE) {
-			bind_result = ldap_simple_bind_s(ldapConn, NULL, NULL);
+			res = ldap_simple_bind_s(ldapConn, NULL, NULL);
 		} else {
 			/* connect via sasl */
+		
 		}
 	}
 	
-	if (bind_result == LDAP_SUCCESS) {
+	if (res == LDAP_SUCCESS) {
 		if (option_debug > 1)
 			ast_log(LOG_DEBUG, "Successfully connected to database.\n");
 		connect_time = time(NULL);
 		return 1;
 	} else {
-		ast_log(LOG_WARNING, "bind failed: %s\n", ldap_err2string(bind_result));
+		ast_log(LOG_WARNING, "bind failed: %s\n", ldap_err2string(res));
 		ldap_unbind(ldapConn);
 		ldapConn = NULL;
 		return 0;



More information about the svn-commits mailing list