2 Unix SMB/CIFS implementation.
3 ads (active directory) utility library
5 Copyright (C) Stefan (metze) Metzmacher 2002
6 Copyright (C) Andrew Tridgell 2001
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 translated the ACB_CTRL Flags to UserFlags (userAccountControl)
28 uint32
ads_acb2uf(uint16 acb
)
30 uint32 uf
= 0x00000000;
32 if (acb
& ACB_DISABLED
) uf
|= UF_ACCOUNTDISABLE
;
33 if (acb
& ACB_HOMDIRREQ
) uf
|= UF_HOMEDIR_REQUIRED
;
34 if (acb
& ACB_PWNOTREQ
) uf
|= UF_PASSWD_NOTREQD
;
35 if (acb
& ACB_TEMPDUP
) uf
|= UF_TEMP_DUPLICATE_ACCOUNT
;
36 if (acb
& ACB_NORMAL
) uf
|= UF_NORMAL_ACCOUNT
;
37 if (acb
& ACB_MNS
) uf
|= UF_MNS_LOGON_ACCOUNT
;
38 if (acb
& ACB_DOMTRUST
) uf
|= UF_INTERDOMAIN_TRUST_ACCOUNT
;
39 if (acb
& ACB_WSTRUST
) uf
|= UF_WORKSTATION_TRUST_ACCOUNT
;
40 if (acb
& ACB_SVRTRUST
) uf
|= UF_SERVER_TRUST_ACCOUNT
;
41 if (acb
& ACB_PWNOEXP
) uf
|= UF_DONT_EXPIRE_PASSWD
;
42 if (acb
& ACB_AUTOLOCK
) uf
|= UF_LOCKOUT
;
48 translated the UserFlags (userAccountControl) to ACB_CTRL Flags
50 uint16
ads_uf2acb(uint32 uf
)
54 if (uf
& UF_ACCOUNTDISABLE
) acb
|= ACB_DISABLED
;
55 if (uf
& UF_HOMEDIR_REQUIRED
) acb
|= ACB_HOMDIRREQ
;
56 if (uf
& UF_PASSWD_NOTREQD
) acb
|= ACB_PWNOTREQ
;
57 if (uf
& UF_MNS_LOGON_ACCOUNT
) acb
|= ACB_MNS
;
58 if (uf
& UF_DONT_EXPIRE_PASSWD
) acb
|= ACB_PWNOEXP
;
59 if (uf
& UF_LOCKOUT
) acb
|= ACB_AUTOLOCK
;
61 switch (uf
& UF_ACCOUNT_TYPE_MASK
)
63 case UF_TEMP_DUPLICATE_ACCOUNT
: acb
|= ACB_TEMPDUP
;break;
64 case UF_NORMAL_ACCOUNT
: acb
|= ACB_NORMAL
;break;
65 case UF_INTERDOMAIN_TRUST_ACCOUNT
: acb
|= ACB_DOMTRUST
;break;
66 case UF_WORKSTATION_TRUST_ACCOUNT
: acb
|= ACB_WSTRUST
;break;
67 case UF_SERVER_TRUST_ACCOUNT
: acb
|= ACB_SVRTRUST
;break;
68 /*Fix Me: what should we do here? */
69 default: acb
|= ACB_NORMAL
;break;
76 get the accountType from the UserFlags
78 uint32
ads_uf2atype(uint32 uf
)
80 uint32 atype
= 0x00000000;
82 if (uf
& UF_NORMAL_ACCOUNT
) atype
= ATYPE_NORMAL_ACCOUNT
;
83 else if (uf
& UF_TEMP_DUPLICATE_ACCOUNT
) atype
= ATYPE_NORMAL_ACCOUNT
;
84 else if (uf
& UF_SERVER_TRUST_ACCOUNT
) atype
= ATYPE_WORKSTATION_TRUST
;
85 else if (uf
& UF_WORKSTATION_TRUST_ACCOUNT
) atype
= ATYPE_WORKSTATION_TRUST
;
86 else if (uf
& UF_INTERDOMAIN_TRUST_ACCOUNT
) atype
= ATYPE_INTERDOMAIN_TRUST
;
92 get the accountType from the groupType
94 uint32
ads_gtype2atype(uint32 gtype
)
96 uint32 atype
= 0x00000000;
99 case GTYPE_SECURITY_BUILTIN_LOCAL_GROUP
:
100 atype
= ATYPE_SECURITY_LOCAL_GROUP
;
102 case GTYPE_SECURITY_DOMAIN_LOCAL_GROUP
:
103 atype
= ATYPE_SECURITY_LOCAL_GROUP
;
105 case GTYPE_SECURITY_GLOBAL_GROUP
:
106 atype
= ATYPE_SECURITY_GLOBAL_GROUP
;
109 case GTYPE_DISTRIBUTION_GLOBAL_GROUP
:
110 atype
= ATYPE_DISTRIBUTION_GLOBAL_GROUP
;
112 case GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP
:
113 atype
= ATYPE_DISTRIBUTION_UNIVERSAL_GROUP
;
115 case GTYPE_DISTRIBUTION_UNIVERSAL_GROUP
:
116 atype
= ATYPE_DISTRIBUTION_LOCAL_GROUP
;
123 /* turn a sAMAccountType into a SID_NAME_USE */
124 enum SID_NAME_USE
ads_atype_map(uint32 atype
)
126 switch (atype
& 0xF0000000) {
127 case ATYPE_GLOBAL_GROUP
:
128 return SID_NAME_DOM_GRP
;
129 case ATYPE_SECURITY_LOCAL_GROUP
:
130 return SID_NAME_ALIAS
;
132 return SID_NAME_USER
;
134 DEBUG(1,("hmm, need to map account type 0x%x\n", atype
));
136 return SID_NAME_UNKNOWN
;