summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-05-16 01:22:28 +0200
committerGünther Deschner <gd@samba.org>2009-05-16 01:27:51 +0200
commitdccecdf33850ec4d763b8b0e7ba7be7a8eb873de (patch)
tree711c98d654374d95b4b523685689a5c625c7842d
parent118f343b05ba86a1f8fd28394433aa6e961e2d6c (diff)
downloadsamba-dccecdf33850ec4d763b8b0e7ba7be7a8eb873de.tar.gz
samba-dccecdf33850ec4d763b8b0e7ba7be7a8eb873de.tar.bz2
samba-dccecdf33850ec4d763b8b0e7ba7be7a8eb873de.zip
s3-privileges: add privilege_delete_account().
Guenther
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/lib/privileges.c28
2 files changed, 29 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index fd49050c38..f6b2b3ca2d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -597,6 +597,7 @@ bool revoke_privilege(const DOM_SID *sid, const SE_PRIV *priv_mask);
bool revoke_all_privileges( DOM_SID *sid );
bool revoke_privilege_by_name(DOM_SID *sid, const char *name);
NTSTATUS privilege_create_account(const DOM_SID *sid );
+NTSTATUS privilege_delete_account(const struct dom_sid *sid);
NTSTATUS privilege_set_init(PRIVILEGE_SET *priv_set);
NTSTATUS privilege_set_init_by_ctx(TALLOC_CTX *mem_ctx, PRIVILEGE_SET *priv_set);
void privilege_set_free(PRIVILEGE_SET *priv_set);
diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c
index b3574da858..c8be360dc6 100644
--- a/source3/lib/privileges.c
+++ b/source3/lib/privileges.c
@@ -359,6 +359,34 @@ NTSTATUS privilege_create_account(const DOM_SID *sid )
return ( grant_privilege(sid, &se_priv_none) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL);
}
+/***************************************************************************
+ Delete a privileged account
+****************************************************************************/
+
+NTSTATUS privilege_delete_account(const struct dom_sid *sid)
+{
+ struct db_context *db = get_account_pol_db();
+ fstring tmp, keystr;
+
+ if (!lp_enable_privileges()) {
+ return NT_STATUS_OK;
+ }
+
+ if (!db) {
+ return NT_STATUS_INVALID_HANDLE;
+ }
+
+ if (!sid || (sid->num_auths == 0)) {
+ return NT_STATUS_INVALID_SID;
+ }
+
+ /* PRIV_<SID> (NULL terminated) as the key */
+
+ fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_fstring(tmp, sid));
+
+ return dbwrap_delete_bystring(db, keystr);
+}
+
/****************************************************************************
initialise a privilege list and set the talloc context
****************************************************************************/