summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-06-01 16:37:28 +1000
committerAndrew Tridgell <tridge@samba.org>2009-06-01 16:37:28 +1000
commitc0213308bbde59270f681ce7c55a44bda34a980f (patch)
tree3e993812e45eb0933fde3010cdc3fc35291b8fca
parentce1045983fd294b95dfe91524b5d8b80a35df448 (diff)
downloadsamba-c0213308bbde59270f681ce7c55a44bda34a980f.tar.gz
samba-c0213308bbde59270f681ce7c55a44bda34a980f.tar.bz2
samba-c0213308bbde59270f681ce7c55a44bda34a980f.zip
we don't need the unique checks in the samldb code now
These attributes now use the unique indexing flag
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c164
1 files changed, 2 insertions, 162 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 65e36416f1..dad5ff2e80 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -466,91 +466,19 @@ static int samldb_generate_samAccountName(struct ldb_message *msg)
return ldb_msg_add_steal_string(msg, "samAccountName", name);
}
-static int samldb_check_samAccountName_callback(struct ldb_request *req,
- struct ldb_reply *ares)
-{
- struct samldb_ctx *ac;
- int ret;
-
- ac = talloc_get_type(req->context, struct samldb_ctx);
-
- if (!ares) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
- }
- if (ares->error != LDB_SUCCESS) {
- return ldb_module_done(ac->req, ares->controls,
- ares->response, ares->error);
- }
-
- switch (ares->type) {
- case LDB_REPLY_ENTRY:
-
- /* if we get an entry it means this samAccountName
- * already exists */
- return ldb_module_done(ac->req, NULL, NULL,
- LDB_ERR_ENTRY_ALREADY_EXISTS);
-
- case LDB_REPLY_REFERRAL:
- /* ignore */
- talloc_free(ares);
- ret = LDB_SUCCESS;
- break;
-
- case LDB_REPLY_DONE:
-
- /* not found, go on */
- talloc_free(ares);
- ret = samldb_next_step(ac);
- break;
- }
-
-done:
- if (ret != LDB_SUCCESS) {
- return ldb_module_done(ac->req, NULL, NULL, ret);
- }
-
- return LDB_SUCCESS;
-}
static int samldb_check_samAccountName(struct samldb_ctx *ac)
{
- struct ldb_context *ldb;
- struct ldb_request *req;
- const char *name;
- char *filter;
int ret;
- ldb = ldb_module_get_ctx(ac->module);
-
if (ldb_msg_find_element(ac->msg, "samAccountName") == NULL) {
ret = samldb_generate_samAccountName(ac->msg);
if (ret != LDB_SUCCESS) {
return ret;
}
}
-
- name = ldb_msg_find_attr_as_string(ac->msg, "samAccountName", NULL);
- if (name == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
- filter = talloc_asprintf(ac, "samAccountName=%s", name);
- if (filter == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ret = ldb_build_search_req(&req, ldb, ac,
- ac->domain_dn, LDB_SCOPE_SUBTREE,
- filter, NULL,
- NULL,
- ac, samldb_check_samAccountName_callback,
- ac->req);
- talloc_free(filter);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- ac->ares = NULL;
- return ldb_next_request(ac->module, req);
+
+ return samldb_next_step(ac);
}
static int samldb_check_samAccountType(struct samldb_ctx *ac)
@@ -768,87 +696,6 @@ static int samldb_new_sid(struct samldb_ctx *ac)
return samldb_next_step(ac);
}
-static int samldb_check_sid_callback(struct ldb_request *req,
- struct ldb_reply *ares)
-{
- struct samldb_ctx *ac;
- int ret;
-
- ac = talloc_get_type(req->context, struct samldb_ctx);
-
- if (!ares) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
- }
- if (ares->error != LDB_SUCCESS) {
- return ldb_module_done(ac->req, ares->controls,
- ares->response, ares->error);
- }
-
- switch (ares->type) {
- case LDB_REPLY_ENTRY:
-
- /* if we get an entry it means an object with the
- * requested sid exists */
- return ldb_module_done(ac->req, NULL, NULL,
- LDB_ERR_CONSTRAINT_VIOLATION);
-
- case LDB_REPLY_REFERRAL:
- /* ignore */
- talloc_free(ares);
- break;
-
- case LDB_REPLY_DONE:
-
- /* not found, go on */
- talloc_free(ares);
- ret = samldb_next_step(ac);
- break;
- }
-
-done:
- if (ret != LDB_SUCCESS) {
- return ldb_module_done(ac->req, NULL, NULL, ret);
- }
-
- return LDB_SUCCESS;
-}
-
-static int samldb_check_sid(struct samldb_ctx *ac)
-{
- struct ldb_context *ldb;
- const char *const attrs[2] = { "objectSid", NULL };
- struct ldb_request *req;
- char *filter;
- int ret;
-
- if (ac->sid == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ldb = ldb_module_get_ctx(ac->module);
-
- filter = talloc_asprintf(ac, "(objectSid=%s)",
- ldap_encode_ndr_dom_sid(ac, ac->sid));
- if (filter == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ret = ldb_build_search_req(&req, ldb, ac,
- ldb_get_default_basedn(ldb),
- LDB_SCOPE_SUBTREE,
- filter, attrs,
- NULL,
- ac, samldb_check_sid_callback,
- ac->req);
-
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- return ldb_next_request(ac->module, req);
-}
-
static int samldb_notice_sid_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
@@ -1051,9 +898,6 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type)
if (ret != LDB_SUCCESS) return ret;
}
- ret = samldb_add_step(ac, samldb_check_sid);
- if (ret != LDB_SUCCESS) return ret;
-
ret = samldb_add_step(ac, samldb_notice_sid);
if (ret != LDB_SUCCESS) return ret;
@@ -1228,10 +1072,6 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct samldb_ctx *ac)
ret = samldb_add_step(ac, samldb_apply_template);
if (ret != LDB_SUCCESS) return ret;
- /* check we do not already have this SID */
- ret = samldb_add_step(ac, samldb_check_sid);
- if (ret != LDB_SUCCESS) return ret;
-
/* check if we need to notice this SID */
ret = samldb_add_step(ac, samldb_foreign_notice_sid);
if (ret != LDB_SUCCESS) return ret;