diff options
author | Volker Lendecke <vl@samba.org> | 2009-06-07 23:32:36 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-06-08 21:14:10 +0200 |
commit | 5ea88420da78589b3d52addcd8cce119968f0f73 (patch) | |
tree | b63c22f516999abe588e9b800fc14296fb701681 /source3/passdb | |
parent | 66c3cd1e9237fa605d725c1020a37fe61143bf4a (diff) | |
download | samba-5ea88420da78589b3d52addcd8cce119968f0f73.tar.gz samba-5ea88420da78589b3d52addcd8cce119968f0f73.tar.bz2 samba-5ea88420da78589b3d52addcd8cce119968f0f73.zip |
Implement pdb_ads_delete_alias
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_ads.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/source3/passdb/pdb_ads.c b/source3/passdb/pdb_ads.c index 26bf176aaf..1bfbdf0dce 100644 --- a/source3/passdb/pdb_ads.c +++ b/source3/passdb/pdb_ads.c @@ -878,7 +878,50 @@ static NTSTATUS pdb_ads_create_alias(struct pdb_methods *m, static NTSTATUS pdb_ads_delete_alias(struct pdb_methods *m, const DOM_SID *sid) { - return NT_STATUS_NOT_IMPLEMENTED; + struct pdb_ads_state *state = talloc_get_type_abort( + m->private_data, struct pdb_ads_state); + struct tldap_message **alias; + char *sidstr, *dn; + int rc; + + sidstr = sid_binstring(talloc_tos(), sid); + if (sidstr == NULL) { + return NT_STATUS_NO_MEMORY; + } + + rc = tldap_search_fmt(state->ld, state->domaindn, TLDAP_SCOPE_SUB, + NULL, 0, 0, talloc_tos(), &alias, + "(&(objectSid=%s)(objectclass=group)" + "(|(grouptype=%d)(grouptype=%d)))", + sidstr, GTYPE_SECURITY_BUILTIN_LOCAL_GROUP, + GTYPE_SECURITY_DOMAIN_LOCAL_GROUP); + TALLOC_FREE(sidstr); + if (rc != TLDAP_SUCCESS) { + DEBUG(10, ("ldap_search failed: %s\n", + tldap_errstr(debug_ctx(), state->ld, rc))); + TALLOC_FREE(dn); + return NT_STATUS_LDAP(rc); + } + if (talloc_array_length(alias) != 1) { + DEBUG(10, ("Expected 1 alias, got %d\n", + talloc_array_length(alias))); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + if (!tldap_entry_dn(alias[0], &dn)) { + DEBUG(10, ("Could not get DN for alias %s\n", + sid_string_dbg(sid))); + return NT_STATUS_INTERNAL_ERROR; + } + + rc = tldap_delete(state->ld, dn, NULL, NULL); + if (rc != TLDAP_SUCCESS) { + DEBUG(10, ("ldap_delete failed: %s\n", + tldap_errstr(debug_ctx(), state->ld, rc))); + TALLOC_FREE(dn); + return NT_STATUS_LDAP(rc); + } + + return NT_STATUS_OK; } static NTSTATUS pdb_ads_get_aliasinfo(struct pdb_methods *m, |