45 #else |
45 #else |
46 ldap_unbind_ext_s(ldap, NULL, NULL); |
46 ldap_unbind_ext_s(ldap, NULL, NULL); |
47 #endif |
47 #endif |
48 } |
48 } |
49 |
49 |
50 AuthDB* create_ldap_authdb(char *name, LDAPConfig *conf) { |
50 AuthDB* create_ldap_authdb(ServerConfiguration *cfg, const char *name, LDAPConfig *conf) { |
51 LDAPAuthDB *authdb = malloc(sizeof(LDAPAuthDB)); |
51 LDAPAuthDB *authdb = almalloc(cfg->a, sizeof(LDAPAuthDB)); |
52 authdb->authdb.name = strdup(name); |
52 authdb->authdb.name = pool_strdup(cfg->pool, name); |
53 authdb->authdb.get_user = ldap_get_user; |
53 authdb->authdb.get_user = ldap_get_user; |
54 authdb->authdb.use_cache = 1; |
54 authdb->authdb.use_cache = 1; |
55 authdb->config = *conf; |
55 authdb->config = *conf; |
56 |
56 |
57 if (!authdb->config.usersearch) { |
57 if (!authdb->config.usersearch) { |
62 } |
62 } |
63 |
63 |
64 // initialize group cache |
64 // initialize group cache |
65 authdb->groups.first = NULL; |
65 authdb->groups.first = NULL; |
66 authdb->groups.last = NULL; |
66 authdb->groups.last = NULL; |
67 authdb->groups.map = ucx_map_new(32); |
67 authdb->groups.map = ucx_map_new_a(cfg->a, 32); |
68 |
68 |
69 return (AuthDB*) authdb; |
69 return (AuthDB*) authdb; |
70 } |
70 } |
71 |
71 |
72 LDAP* get_ldap_session(LDAPAuthDB *authdb) { |
72 LDAP* get_ldap_session(LDAPAuthDB *authdb) { |