s4:libds/common/flags.h - fix typo
[samba.git] / libds / common / flag_mapping.c
index 429ccacb490b8713c6dde7587450a290350e8a4a..99421ed533fa1fb8c01b73938dc59ae78ef91c33 100644 (file)
@@ -4,6 +4,7 @@
 
    Copyright (C) Stefan (metze) Metzmacher 2002
    Copyright (C) Andrew Tridgell 2004
 
    Copyright (C) Stefan (metze) Metzmacher 2002
    Copyright (C) Andrew Tridgell 2004
+   Copyright (C) Matthias Dieter Wallnöfer 2010
 
    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
 
    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
@@ -49,12 +50,16 @@ static const struct {
        { 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_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 }
+       { UF_NO_AUTH_DATA_REQUIRED, ACB_NO_AUTH_DATA_REQD },
+       { UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION, ACB_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION },
+       { UF_PARTIAL_SECRETS_ACCOUNT, ACB_PARTIAL_SECRETS_ACCOUNT },
+       { UF_USE_AES_KEYS, ACB_USE_AES_KEYS }
 };
 
 uint32_t ds_acb2uf(uint32_t acb)
 {
 };
 
 uint32_t ds_acb2uf(uint32_t acb)
 {
-       uint32_t i, ret = 0;
+       unsigned int i;
+       uint32_t 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;
        for (i=0;i<ARRAY_SIZE(acct_flags_map);i++) {
                if (acct_flags_map[i].acb & acb) {
                        ret |= acct_flags_map[i].uf;
@@ -68,7 +73,7 @@ translated the UserFlags (userAccountControl) to ACB_CTRL Flags
 */
 uint32_t ds_uf2acb(uint32_t uf)
 {
 */
 uint32_t ds_uf2acb(uint32_t uf)
 {
-       uint32_t i;
+       unsigned int i;
        uint32_t ret = 0;
        for (i=0;i<ARRAY_SIZE(acct_flags_map);i++) {
                if (acct_flags_map[i].uf & uf) {
        uint32_t ret = 0;
        for (i=0;i<ARRAY_SIZE(acct_flags_map);i++) {
                if (acct_flags_map[i].uf & uf) {
@@ -144,3 +149,17 @@ enum lsa_SidType ds_atype_map(uint32_t atype)
        }
        return SID_NAME_UNKNOWN;
 }
        }
        return SID_NAME_UNKNOWN;
 }
+
+/* get the default primary group RID for a given userAccountControl
+ * (informations according to MS-SAMR 3.1.1.8.1) */
+uint32_t ds_uf2prim_group_rid(uint32_t uf)
+{
+       uint32_t prim_group_rid = DOMAIN_RID_USERS;
+
+       if ((uf & UF_PARTIAL_SECRETS_ACCOUNT)
+        && (uf & UF_WORKSTATION_TRUST_ACCOUNT))    prim_group_rid = DOMAIN_RID_READONLY_DCS;
+       else if (uf & UF_SERVER_TRUST_ACCOUNT)      prim_group_rid = DOMAIN_RID_DCS;
+       else if (uf & UF_WORKSTATION_TRUST_ACCOUNT) prim_group_rid = DOMAIN_RID_DOMAIN_MEMBERS;
+
+       return prim_group_rid;
+}