diff options
author | Kamen Mazdrashki <kamenim@samba.org> | 2015-01-12 04:46:38 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-02-03 05:02:12 +0100 |
commit | b37f7e619048593e267271f1b30af3f915fc422b (patch) | |
tree | a2c0c40719c46807125f7e12fa1ea6f01476e891 /source4/dsdb/common/util.c | |
parent | c9b0945199080b72ad454d49b310be0b66410124 (diff) | |
download | samba-b37f7e619048593e267271f1b30af3f915fc422b.tar.gz samba-b37f7e619048593e267271f1b30af3f915fc422b.tar.xz samba-b37f7e619048593e267271f1b30af3f915fc422b.zip |
s4-dsdb: Common helper for setting "sAMAccountType" on User objects
Change-Id: I4480e7d1ed0c754e960028e0be9a90ee56935e94
Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dsdb/common/util.c')
-rw-r--r-- | source4/dsdb/common/util.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 35d7b65b37..821ea56d68 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -4886,3 +4886,39 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb, struct ldb_message *usr_ return LDB_SUCCESS; } + +/** + * Sets 'sAMAccountType on user object based on userAccountControl + * @param ldb Current ldb_context + * @param usr_obj ldb_message representing User object + * @param user_account_control Value for userAccountControl flags + * @param account_type_p Optional pointer to account_type to return + * @return LDB_SUCCESS or LDB_ERR* code on failure + */ +int dsdb_user_obj_set_account_type(struct ldb_context *ldb, struct ldb_message *usr_obj, + uint32_t user_account_control, uint32_t *account_type_p) +{ + int ret; + uint32_t account_type; + struct ldb_message_element *el; + + account_type = ds_uf2atype(user_account_control); + if (account_type == 0) { + ldb_set_errstring(ldb, "dsdb: Unrecognized account type!"); + return LDB_ERR_UNWILLING_TO_PERFORM; + } + ret = samdb_msg_add_uint(ldb, usr_obj, usr_obj, + "sAMAccountType", + account_type); + if (ret != LDB_SUCCESS) { + return ret; + } + el = ldb_msg_find_element(usr_obj, "sAMAccountType"); + el->flags = LDB_FLAG_MOD_REPLACE; + + if (account_type_p) { + *account_type_p = account_type; + } + + return LDB_SUCCESS; +} |