[asterisk-commits] anthonyl: branch anthonyl/ldap-redux r47896 -
/team/anthonyl/ldap-redux/res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Nov 21 10:19:44 MST 2006
Author: anthonyl
Date: Tue Nov 21 11:19:43 2006
New Revision: 47896
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47896
Log:
some small changes, nothing to importent
Modified:
team/anthonyl/ldap-redux/res/res_config_ldap.c
Modified: team/anthonyl/ldap-redux/res/res_config_ldap.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/ldap-redux/res/res_config_ldap.c?view=diff&rev=47896&r1=47895&r2=47896
==============================================================================
--- team/anthonyl/ldap-redux/res/res_config_ldap.c (original)
+++ team/anthonyl/ldap-redux/res/res_config_ldap.c Tue Nov 21 11:19:43 2006
@@ -53,22 +53,29 @@
#include "asterisk/pbx.h"
#include "asterisk/linkedlists.h"
+#define RES_CONFIG_LDAP_CONF "res_ldap.conf"
+
+#define LDAP_AUTH_SIMPLE 1
+#define LDAP_AUTH_SASL 2
+
static char *res_config_ldap_desc = "LDAP RealTime Configuration Driver";
+
+/* note to me: group these into a structure */
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 int ldapversion = LDAP_VERSION3;
+static int ldapauthtype = LDAP_AUTH_SIMPLE; /* default to simple authencation */
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;
@@ -77,6 +84,13 @@
char *variable_value;
};
+/*! \brief Table configuration */
+struct ldap_table_config {
+ char *table_name;
+ char *additional_filter;
+ struct ast_variable *attributes;
+ struct ldap_table_config *next;
+};
static char cli_realtime_ldap_status_usage[] =
"Usage: realtime ldap status\n"
" Shows connection information for the LDAP RealTime driver\n";
@@ -87,14 +101,6 @@
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;
@@ -103,8 +109,10 @@
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;
}
@@ -1006,7 +1014,7 @@
ast_copy_string(dbpass, "asterisk", sizeof(dbpass) - 1);
} else
ast_copy_string(dbpass, s, sizeof(dbpass));
-
+
if (!(s = ast_variable_retrieve(config, "_general", "dbhost"))) {
ast_log(LOG_ERROR, "No directory host found.\n");
dbhost[0] = '\0';
@@ -1024,7 +1032,18 @@
dbport = 389;
} else
dbport = atoi(s);
-
+ if (!(s = ast_variable_retrieve(config, "_general", "ldapversion"))) {
+ ldapversion = LDAP_VERSION3;
+ } else
+ switch (atoi(s)) {
+ case '2':
+ ldapversion = LDAP_VERSION2;
+ break;
+ case '3':
+ default:
+ ldapversion = LDAP_VERSION3;
+ break;
+ }
table_configs_free();
char *category_name = NULL;
@@ -1100,14 +1119,17 @@
return 0;
}
+ ldap_set_option(ldapConn, LDAP_OPT_PROTOCOL_VERSION, &ldapversion);
+
if (dbuser && *dbuser) {
if (option_debug > 1)
ast_log(LOG_DEBUG, "bind to %s as %s\n", dbhost, dbuser);
- bind_result = ldap_simple_bind_s(ldapConn, dbuser, dbpass);
+ /* we should support more authencation options and dbUser should be dn */
+ bind_result = ldap_bind_s(ldapConn, dbUser, dbPass, LDAP_AUTH_SIMPLE);
} else {
if (option_debug > 1)
ast_log(LOG_DEBUG, "bind anonymously %s anonymously\n", dbhost);
- bind_result = ldap_simple_bind_s(ldapConn, NULL, NULL);
+ bind_result = ldap_bind_s(ldapConn, dbUser, dbPass, LDAP_AUTH_SIMPLE);
}
if (bind_result == LDAP_SUCCESS) {
if (option_debug > 1)
More information about the asterisk-commits
mailing list