/* Looks like we didn't get a bind. Open a new session... */
if (!lc) {
- ld = ldap_init(li->host, li->port);
- if (!ld) {
+ if (ldap_initialize(&ld, li->url) != LDAP_SUCCESS) {
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "ldap_init failed", NULL, NULL );
return( NULL );
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
- char *port;
if ( li == NULL ) {
fprintf( stderr, "%s: line %d: ldap backend info is null!\n",
return( 1 );
}
- /* server address to query */
+ /* server address to query (depricated, use "uri" directive) */
if ( strcasecmp( argv[0], "server" ) == 0 ) {
if (argc != 2) {
fprintf( stderr,
fname, lineno );
return( 1 );
}
- port=strchr(argv[1],':');
- if (port) {
- *port++ = '\0';
- li->port = atoi(port);
+ if (li->url != NULL)
+ ch_free(li->url);
+ li->url = ch_calloc(strlen(argv[1]) + 9, sizeof(char));
+ if (li->url != NULL) {
+ strcpy(li->url, "ldap://");
+ strcat(li->url, argv[1]);
+ strcat(li->url, "/");
}
- li->host = ch_strdup(argv[1]);
+
+ /* URI of server to query (preferred over "server" directive) */
+ } else if ( strcasecmp( argv[0], "uri" ) == 0 ) {
+ if (argc != 2) {
+ fprintf( stderr,
+ "%s: line %d: missing address in \"uri <address>\" line\n",
+ fname, lineno );
+ return( 1 );
+ }
+ if (li->url != NULL)
+ ch_free(li->url);
+ li->url = ch_strdup(argv[1]);
+
+ /* name to use for ldap_back_group */
+ } else if ( strcasecmp( argv[0], "binddn" ) == 0 ) {
+ if (argc != 2) {
+ fprintf( stderr,
+ "%s: line %d: missing name in \"binddn <name>\" line\n",
+ fname, lineno );
+ return( 1 );
+ }
+ li->binddn = ch_strdup(argv[1]);
+
+ /* password to use for ldap_back_group */
+ } else if ( strcasecmp( argv[0], "bindpw" ) == 0 ) {
+ if (argc != 2) {
+ fprintf( stderr,
+ "%s: line %d: missing password in \"bindpw <password>\" line\n",
+ fname, lineno );
+ return( 1 );
+ }
+ li->bindpw = ch_strdup(argv[1]);
+
/* anything else */
} else {
fprintf( stderr,