diff options
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/common/flag_mapping.c | 145 | ||||
-rw-r--r-- | source4/dsdb/common/sidmap.c | 4 | ||||
-rw-r--r-- | source4/dsdb/common/util.c | 4 | ||||
-rw-r--r-- | source4/dsdb/config.mk | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/samldb.c | 8 |
5 files changed, 10 insertions, 155 deletions
diff --git a/source4/dsdb/common/flag_mapping.c b/source4/dsdb/common/flag_mapping.c deleted file mode 100644 index af284c41e7..0000000000 --- a/source4/dsdb/common/flag_mapping.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - Unix SMB/CIFS implementation. - helper mapping functions for the SAMDB server - - Copyright (C) Stefan (metze) Metzmacher 2002 - Copyright (C) Andrew Tridgell 2004 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "librpc/gen_ndr/samr.h" -#include "../libds/common/flags.h" -#include "lib/ldb/include/ldb.h" -#include "dsdb/common/proto.h" - -/* -translated the ACB_CTRL Flags to UserFlags (userAccountControl) -*/ -/* mapping between ADS userAccountControl and SAMR acct_flags */ -static const struct { - uint32_t uf; - uint32_t acb; -} acct_flags_map[] = { - { UF_ACCOUNTDISABLE, ACB_DISABLED }, - { UF_HOMEDIR_REQUIRED, ACB_HOMDIRREQ }, - { UF_PASSWD_NOTREQD, ACB_PWNOTREQ }, - { UF_TEMP_DUPLICATE_ACCOUNT, ACB_TEMPDUP }, - { UF_NORMAL_ACCOUNT, ACB_NORMAL }, - { UF_MNS_LOGON_ACCOUNT, ACB_MNS }, - { UF_INTERDOMAIN_TRUST_ACCOUNT, ACB_DOMTRUST }, - { UF_WORKSTATION_TRUST_ACCOUNT, ACB_WSTRUST }, - { UF_SERVER_TRUST_ACCOUNT, ACB_SVRTRUST }, - { UF_DONT_EXPIRE_PASSWD, ACB_PWNOEXP }, - { UF_LOCKOUT, ACB_AUTOLOCK }, - { UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED, ACB_ENC_TXT_PWD_ALLOWED }, - { UF_SMARTCARD_REQUIRED, ACB_SMARTCARD_REQUIRED }, - { UF_TRUSTED_FOR_DELEGATION, ACB_TRUSTED_FOR_DELEGATION }, - { UF_NOT_DELEGATED, ACB_NOT_DELEGATED }, - { UF_USE_DES_KEY_ONLY, ACB_USE_DES_KEY_ONLY}, - { UF_DONT_REQUIRE_PREAUTH, ACB_DONT_REQUIRE_PREAUTH }, - { UF_PASSWORD_EXPIRED, ACB_PW_EXPIRED }, - { UF_NO_AUTH_DATA_REQUIRED, ACB_NO_AUTH_DATA_REQD } -}; - -uint32_t samdb_acb2uf(uint32_t acb) -{ - uint32_t i, ret = 0; - for (i=0;i<ARRAY_SIZE(acct_flags_map);i++) { - if (acct_flags_map[i].acb & acb) { - ret |= acct_flags_map[i].uf; - } - } - return ret; -} - -/* -translated the UserFlags (userAccountControl) to ACB_CTRL Flags -*/ -uint32_t samdb_uf2acb(uint32_t uf) -{ - uint32_t i; - uint32_t ret = 0; - for (i=0;i<ARRAY_SIZE(acct_flags_map);i++) { - if (acct_flags_map[i].uf & uf) { - ret |= acct_flags_map[i].acb; - } - } - return ret; -} - -/* -get the accountType from the UserFlags -*/ -uint32_t samdb_uf2atype(uint32_t uf) -{ - uint32_t atype = 0x00000000; - - if (uf & UF_NORMAL_ACCOUNT) atype = ATYPE_NORMAL_ACCOUNT; - else if (uf & UF_TEMP_DUPLICATE_ACCOUNT) atype = ATYPE_NORMAL_ACCOUNT; - else if (uf & UF_SERVER_TRUST_ACCOUNT) atype = ATYPE_WORKSTATION_TRUST; - else if (uf & UF_WORKSTATION_TRUST_ACCOUNT) atype = ATYPE_WORKSTATION_TRUST; - else if (uf & UF_INTERDOMAIN_TRUST_ACCOUNT) atype = ATYPE_INTERDOMAIN_TRUST; - - return atype; -} - -/* -get the accountType from the groupType -*/ -uint32_t samdb_gtype2atype(uint32_t gtype) -{ - uint32_t atype = 0x00000000; - - switch(gtype) { - case GTYPE_SECURITY_BUILTIN_LOCAL_GROUP: - atype = ATYPE_SECURITY_LOCAL_GROUP; - break; - case GTYPE_SECURITY_DOMAIN_LOCAL_GROUP: - atype = ATYPE_SECURITY_LOCAL_GROUP; - break; - case GTYPE_SECURITY_GLOBAL_GROUP: - atype = ATYPE_SECURITY_GLOBAL_GROUP; - break; - - case GTYPE_DISTRIBUTION_GLOBAL_GROUP: - atype = ATYPE_DISTRIBUTION_GLOBAL_GROUP; - break; - case GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP: - atype = ATYPE_DISTRIBUTION_UNIVERSAL_GROUP; - break; - case GTYPE_DISTRIBUTION_UNIVERSAL_GROUP: - atype = ATYPE_DISTRIBUTION_LOCAL_GROUP; - break; - } - - return atype; -} - -/* turn a sAMAccountType into a SID_NAME_USE */ -enum lsa_SidType samdb_atype_map(uint32_t atype) -{ - switch (atype & 0xF0000000) { - case ATYPE_GLOBAL_GROUP: - return SID_NAME_DOM_GRP; - case ATYPE_SECURITY_LOCAL_GROUP: - return SID_NAME_ALIAS; - case ATYPE_ACCOUNT: - return SID_NAME_USER; - default: - DEBUG(1,("hmm, need to map account type 0x%x\n", atype)); - } - return SID_NAME_UNKNOWN; -} diff --git a/source4/dsdb/common/sidmap.c b/source4/dsdb/common/sidmap.c index a2aa717ace..3111a78e51 100644 --- a/source4/dsdb/common/sidmap.c +++ b/source4/dsdb/common/sidmap.c @@ -583,7 +583,7 @@ NTSTATUS sidmap_allocated_sid_lookup(struct sidmap_context *sidmap, struct passwd *pwd; uid_t uid = rid - SIDMAP_LOCAL_USER_BASE; atype = ATYPE_NORMAL_ACCOUNT; - *rtype = samdb_atype_map(atype); + *rtype = ds_atype_map(atype); pwd = getpwuid(uid); if (pwd == NULL) { @@ -595,7 +595,7 @@ NTSTATUS sidmap_allocated_sid_lookup(struct sidmap_context *sidmap, struct group *grp; gid_t gid = rid - SIDMAP_LOCAL_GROUP_BASE; atype = ATYPE_LOCAL_GROUP; - *rtype = samdb_atype_map(atype); + *rtype = ds_atype_map(atype); grp = getgrgid(gid); if (grp == NULL) { *name = talloc_asprintf(mem_ctx, "gid%u", gid); diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 30669ebd5a..247aec7035 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -640,7 +640,7 @@ uint32_t samdb_result_acct_flags(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ct struct ldb_message *msg, struct ldb_dn *domain_dn) { uint32_t userAccountControl = ldb_msg_find_attr_as_uint(msg, "userAccountControl", 0); - uint32_t acct_flags = samdb_uf2acb(userAccountControl); + uint32_t acct_flags = ds_uf2acb(userAccountControl); NTTIME must_change_time; NTTIME now; @@ -902,7 +902,7 @@ int samdb_msg_add_hashes(TALLOC_CTX *mem_ctx, struct ldb_message *msg, int samdb_msg_add_acct_flags(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr_name, uint32_t v) { - return samdb_msg_add_uint(sam_ldb, mem_ctx, msg, attr_name, samdb_acb2uf(v)); + return samdb_msg_add_uint(sam_ldb, mem_ctx, msg, attr_name, ds_acb2uf(v)); } /* diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk index 0438647698..2a9f70fdb5 100644 --- a/source4/dsdb/config.mk +++ b/source4/dsdb/config.mk @@ -26,8 +26,8 @@ PRIVATE_DEPENDENCIES = LIBLDB SAMDB_COMMON_OBJ_FILES = $(addprefix $(dsdbsrcdir)/common/, \ sidmap.o \ - flag_mapping.o \ - util.o) + util.o) \ + ../libds/common/flag_mapping.o $(eval $(call proto_header_template,$(dsdbsrcdir)/common/proto.h,$(SAMDB_COMMON_OBJ_FILES:.o=.c))) [SUBSYSTEM::SAMDB_SCHEMA] diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 8e21e38139..544249cbe3 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -572,7 +572,7 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) "userAccountControl invalid"); return LDB_ERR_UNWILLING_TO_PERFORM; } else { - account_type = samdb_uf2atype(uac); + account_type = ds_uf2atype(uac); ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "sAMAccountType", @@ -590,7 +590,7 @@ static int samldb_check_samAccountType(struct samldb_ctx *ac) "groupType invalid"); return LDB_ERR_UNWILLING_TO_PERFORM; } else { - account_type = samdb_gtype2atype(group_type); + account_type = ds_gtype2atype(group_type); ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg, "sAMAccountType", @@ -1280,7 +1280,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) req->op.mod.message = msg = ldb_msg_copy_shallow(req, req->op.mod.message); group_type = strtoul((const char *)el->values[0].data, NULL, 0); - account_type = samdb_gtype2atype(group_type); + account_type = ds_gtype2atype(group_type); ret = samdb_msg_add_uint(ldb, msg, msg, "sAMAccountType", account_type); @@ -1296,7 +1296,7 @@ static int samldb_modify(struct ldb_module *module, struct ldb_request *req) req->op.mod.message = msg = ldb_msg_copy_shallow(req, req->op.mod.message); user_account_control = strtoul((const char *)el->values[0].data, NULL, 0); - account_type = samdb_uf2atype(user_account_control); + account_type = ds_uf2atype(user_account_control); ret = samdb_msg_add_uint(ldb, msg, msg, "sAMAccountType", account_type); |