static int ldapsrv_load_limits(struct ldapsrv_connection *conn)
{
TALLOC_CTX *tmp_ctx;
+ struct ldb_context *ldb;
const char *attrs[] = { "configurationNamingContext", NULL };
const char *attrs2[] = { "lDAPAdminLimits", NULL };
struct ldb_message_element *el;
conn->limits.max_page_size = 1000;
conn->limits.search_timeout = 120;
-
tmp_ctx = talloc_new(conn);
if (tmp_ctx == NULL) {
return -1;
}
- basedn = ldb_dn_new(tmp_ctx, conn->ldb, NULL);
+ /* Connect to ldb as system to read parameters */
+ ldb = samdb_connect(conn->service, conn->service->task->event_ctx,
+ conn->lp_ctx, system_session(conn->lp_ctx));
+
+ basedn = ldb_dn_new(tmp_ctx, ldb, NULL);
if ( ! ldb_dn_validate(basedn)) {
goto failed;
}
- ret = ldb_search(conn->ldb, tmp_ctx, &res, basedn, LDB_SCOPE_BASE, attrs, NULL);
+ ret = ldb_search(ldb, tmp_ctx, &res, basedn, LDB_SCOPE_BASE, attrs, NULL);
if (ret != LDB_SUCCESS) {
goto failed;
}
goto failed;
}
- conf_dn = ldb_msg_find_attr_as_dn(conn->ldb, tmp_ctx, res->msgs[0], "configurationNamingContext");
+ conf_dn = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, res->msgs[0], "configurationNamingContext");
if (conf_dn == NULL) {
goto failed;
}
goto failed;
}
- ret = ldb_search(conn->ldb, tmp_ctx, &res, policy_dn, LDB_SCOPE_BASE, attrs2, NULL);
+ ret = ldb_search(ldb, tmp_ctx, &res, policy_dn, LDB_SCOPE_BASE, attrs2, NULL);
if (ret != LDB_SUCCESS) {
goto failed;
}
continue;
}
}
-
+ talloc_unlink(conn->service, ldb);
return 0;
failed:
DEBUG(0, ("Failed to load ldap server query policies\n"));
+ talloc_unlink(conn->service, ldb);
talloc_free(tmp_ctx);
return -1;
}