2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Security Account Manager (SAM) Server
4 * FILE: reactos/dll/win32/samsrv/setup.c
5 * PURPOSE: Registry setup routines
7 * PROGRAMMERS: Eric Kohl
14 #include "resources.h"
16 /* GLOBALS *****************************************************************/
18 #define TICKS_PER_SECOND 10000000LL
20 SID_IDENTIFIER_AUTHORITY SecurityNtAuthority
= {SECURITY_NT_AUTHORITY
};
22 /* FUNCTIONS ***************************************************************/
25 SampSetupAddMemberToAlias(HKEY hDomainKey
,
30 LPWSTR MemberSidString
= NULL
;
34 ConvertSidToStringSidW(MemberSid
, &MemberSidString
);
36 swprintf(szKeyName
, L
"Aliases\\%08lX\\Members", AliasId
);
38 if (!RegCreateKeyExW(hDomainKey
,
42 REG_OPTION_NON_VOLATILE
,
48 RegSetValueEx(hMembersKey
,
53 RtlLengthSid(MemberSid
));
55 RegCloseKey(hMembersKey
);
58 swprintf(szKeyName
, L
"Aliases\\Members\\%s", MemberSidString
);
60 if (!RegCreateKeyExW(hDomainKey
,
64 REG_OPTION_NON_VOLATILE
,
70 swprintf(szKeyName
, L
"%08lX", AliasId
);
72 RegSetValueEx(hMembersKey
,
77 RtlLengthSid(MemberSid
));
79 RegCloseKey(hMembersKey
);
82 if (MemberSidString
!= NULL
)
83 LocalFree(MemberSidString
);
91 SampSetupCreateAliasAccount(HANDLE hDomainKey
,
92 LPCWSTR lpAccountName
,
93 LPCWSTR lpDescription
,
96 WCHAR szAccountKeyName
[32];
97 HANDLE hAccountKey
= NULL
;
98 HANDLE hNamesKey
= NULL
;
99 PSECURITY_DESCRIPTOR Sd
= NULL
;
103 swprintf(szAccountKeyName
, L
"Aliases\\%08lX", ulRelativeId
);
105 Status
= SampRegCreateKey(hDomainKey
,
109 if (!NT_SUCCESS(Status
))
112 Status
= SampRegSetValue(hAccountKey
,
115 (LPVOID
)lpAccountName
,
116 (wcslen(lpAccountName
) + 1) * sizeof(WCHAR
));
117 if (!NT_SUCCESS(Status
))
120 Status
= SampRegSetValue(hAccountKey
,
123 (LPVOID
)lpDescription
,
124 (wcslen(lpDescription
) + 1) * sizeof(WCHAR
));
125 if (!NT_SUCCESS(Status
))
128 /* Create the server SD */
129 Status
= SampCreateAliasSD(&Sd
,
131 if (!NT_SUCCESS(Status
))
134 /* Set SecDesc attribute*/
135 Status
= SampRegSetValue(hAccountKey
,
140 if (!NT_SUCCESS(Status
))
143 Status
= SampRegOpenKey(hDomainKey
,
147 if (!NT_SUCCESS(Status
))
150 Status
= SampRegSetValue(hNamesKey
,
153 (LPVOID
)&ulRelativeId
,
157 SampRegCloseKey(&hNamesKey
);
160 RtlFreeHeap(RtlGetProcessHeap(), 0, Sd
);
162 if (hAccountKey
!= NULL
)
164 SampRegCloseKey(&hAccountKey
);
166 if (!NT_SUCCESS(Status
))
167 SampRegDeleteKey(hDomainKey
,
177 SampSetupAddMemberToGroup(IN HANDLE hDomainKey
,
181 WCHAR szKeyName
[256];
182 HANDLE hGroupKey
= NULL
;
183 PULONG MembersBuffer
= NULL
;
184 ULONG MembersCount
= 0;
189 swprintf(szKeyName
, L
"Groups\\%08lX", GroupId
);
191 Status
= SampRegOpenKey(hDomainKey
,
195 if (!NT_SUCCESS(Status
))
198 Status
= SampRegQueryValue(hGroupKey
,
203 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_NOT_FOUND
)
206 MembersBuffer
= midl_user_allocate(Length
+ sizeof(ULONG
));
207 if (MembersBuffer
== NULL
)
209 Status
= STATUS_INSUFFICIENT_RESOURCES
;
213 if (Status
!= STATUS_OBJECT_NAME_NOT_FOUND
)
215 Status
= SampRegQueryValue(hGroupKey
,
220 if (!NT_SUCCESS(Status
))
223 MembersCount
= Length
/ sizeof(ULONG
);
226 for (i
= 0; i
< MembersCount
; i
++)
228 if (MembersBuffer
[i
] == MemberId
)
230 Status
= STATUS_MEMBER_IN_GROUP
;
235 MembersBuffer
[MembersCount
] = MemberId
;
236 Length
+= sizeof(ULONG
);
238 Status
= SampRegSetValue(hGroupKey
,
245 if (MembersBuffer
!= NULL
)
246 midl_user_free(MembersBuffer
);
248 SampRegCloseKey(&hGroupKey
);
256 SampSetupCreateGroupAccount(HANDLE hDomainKey
,
257 LPCWSTR lpAccountName
,
261 SAM_GROUP_FIXED_DATA FixedGroupData
;
262 WCHAR szAccountKeyName
[32];
263 HANDLE hAccountKey
= NULL
;
264 HANDLE hNamesKey
= NULL
;
265 PSECURITY_DESCRIPTOR Sd
= NULL
;
269 /* Initialize fixed group data */
270 FixedGroupData
.Version
= 1;
271 FixedGroupData
.Reserved
= 0;
272 FixedGroupData
.GroupId
= ulRelativeId
;
273 FixedGroupData
.Attributes
= 0;
275 swprintf(szAccountKeyName
, L
"Groups\\%08lX", ulRelativeId
);
277 Status
= SampRegCreateKey(hDomainKey
,
281 if (!NT_SUCCESS(Status
))
284 Status
= SampRegSetValue(hAccountKey
,
287 (LPVOID
)&FixedGroupData
,
288 sizeof(SAM_GROUP_FIXED_DATA
));
289 if (!NT_SUCCESS(Status
))
292 Status
= SampRegSetValue(hAccountKey
,
295 (LPVOID
)lpAccountName
,
296 (wcslen(lpAccountName
) + 1) * sizeof(WCHAR
));
297 if (!NT_SUCCESS(Status
))
300 Status
= SampRegSetValue(hAccountKey
,
304 (wcslen(lpComment
) + 1) * sizeof(WCHAR
));
305 if (!NT_SUCCESS(Status
))
308 /* Create the security descriptor */
309 Status
= SampCreateGroupSD(&Sd
,
311 if (!NT_SUCCESS(Status
))
314 /* Set the SecDesc attribute*/
315 Status
= SampRegSetValue(hAccountKey
,
320 if (!NT_SUCCESS(Status
))
323 Status
= SampRegOpenKey(hDomainKey
,
327 if (!NT_SUCCESS(Status
))
330 Status
= SampRegSetValue(hNamesKey
,
333 (LPVOID
)&ulRelativeId
,
337 SampRegCloseKey(&hNamesKey
);
340 RtlFreeHeap(RtlGetProcessHeap(), 0, Sd
);
342 if (hAccountKey
!= NULL
)
344 SampRegCloseKey(&hAccountKey
);
346 if (!NT_SUCCESS(Status
))
347 SampRegDeleteKey(hDomainKey
,
357 SampSetupCreateUserAccount(HANDLE hDomainKey
,
358 LPCWSTR lpAccountName
,
362 ULONG UserAccountControl
)
364 SAM_USER_FIXED_DATA FixedUserData
;
365 GROUP_MEMBERSHIP GroupMembership
;
366 UCHAR LogonHours
[23];
367 LPWSTR lpEmptyString
= L
"";
368 WCHAR szAccountKeyName
[32];
369 HANDLE hAccountKey
= NULL
;
370 HANDLE hNamesKey
= NULL
;
371 PSECURITY_DESCRIPTOR Sd
= NULL
;
376 UserSid
= AppendRidToSid(lpDomainSid
,
379 /* Create the security descriptor */
380 Status
= SampCreateUserSD(UserSid
,
383 if (!NT_SUCCESS(Status
))
386 /* Initialize fixed user data */
387 FixedUserData
.Version
= 1;
388 FixedUserData
.Reserved
= 0;
389 FixedUserData
.LastLogon
.QuadPart
= 0;
390 FixedUserData
.LastLogoff
.QuadPart
= 0;
391 FixedUserData
.PasswordLastSet
.QuadPart
= 0;
392 FixedUserData
.AccountExpires
.QuadPart
= MAXLONGLONG
;
393 FixedUserData
.LastBadPasswordTime
.QuadPart
= 0;
394 FixedUserData
.UserId
= ulRelativeId
;
395 FixedUserData
.PrimaryGroupId
= DOMAIN_GROUP_RID_USERS
;
396 FixedUserData
.UserAccountControl
= UserAccountControl
;
397 FixedUserData
.CountryCode
= 0;
398 FixedUserData
.CodePage
= 0;
399 FixedUserData
.BadPasswordCount
= 0;
400 FixedUserData
.LogonCount
= 0;
401 FixedUserData
.AdminCount
= 0;
402 FixedUserData
.OperatorCount
= 0;
404 swprintf(szAccountKeyName
, L
"Users\\%08lX", ulRelativeId
);
406 Status
= SampRegCreateKey(hDomainKey
,
410 if (!NT_SUCCESS(Status
))
413 Status
= SampRegSetValue(hAccountKey
,
416 (LPVOID
)&FixedUserData
,
417 sizeof(SAM_USER_FIXED_DATA
));
418 if (!NT_SUCCESS(Status
))
421 Status
= SampRegSetValue(hAccountKey
,
424 (LPVOID
)lpAccountName
,
425 (wcslen(lpAccountName
) + 1) * sizeof(WCHAR
));
426 if (!NT_SUCCESS(Status
))
429 Status
= SampRegSetValue(hAccountKey
,
432 (LPVOID
)lpEmptyString
,
434 if (!NT_SUCCESS(Status
))
437 Status
= SampRegSetValue(hAccountKey
,
440 (LPVOID
)lpEmptyString
,
442 if (!NT_SUCCESS(Status
))
445 Status
= SampRegSetValue(hAccountKey
,
446 L
"HomeDirectoryDrive",
448 (LPVOID
)lpEmptyString
,
450 if (!NT_SUCCESS(Status
))
453 Status
= SampRegSetValue(hAccountKey
,
456 (LPVOID
)lpEmptyString
,
458 if (!NT_SUCCESS(Status
))
461 Status
= SampRegSetValue(hAccountKey
,
464 (LPVOID
)lpEmptyString
,
466 if (!NT_SUCCESS(Status
))
469 Status
= SampRegSetValue(hAccountKey
,
473 (wcslen(lpComment
) + 1) * sizeof(WCHAR
));
474 if (!NT_SUCCESS(Status
))
477 Status
= SampRegSetValue(hAccountKey
,
480 (LPVOID
)lpEmptyString
,
482 if (!NT_SUCCESS(Status
))
485 Status
= SampRegSetValue(hAccountKey
,
488 (LPVOID
)lpEmptyString
,
490 if (!NT_SUCCESS(Status
))
493 Status
= SampRegSetValue(hAccountKey
,
496 (LPVOID
)lpEmptyString
,
498 if (!NT_SUCCESS(Status
))
501 /* Set LogonHours attribute*/
502 *((PUSHORT
)LogonHours
) = 168;
503 memset(&(LogonHours
[2]), 0xff, 21);
505 Status
= SampRegSetValue(hAccountKey
,
510 if (!NT_SUCCESS(Status
))
513 /* Set Groups attribute*/
514 GroupMembership
.RelativeId
= DOMAIN_GROUP_RID_USERS
;
515 GroupMembership
.Attributes
= SE_GROUP_MANDATORY
|
517 SE_GROUP_ENABLED_BY_DEFAULT
;
519 Status
= SampRegSetValue(hAccountKey
,
522 (LPVOID
)&GroupMembership
,
523 sizeof(GROUP_MEMBERSHIP
));
524 if (!NT_SUCCESS(Status
))
527 /* Set LMPwd attribute*/
528 Status
= SampRegSetValue(hAccountKey
,
531 (LPVOID
)&EmptyLmHash
,
532 sizeof(ENCRYPTED_LM_OWF_PASSWORD
));
533 if (!NT_SUCCESS(Status
))
536 /* Set NTPwd attribute*/
537 Status
= SampRegSetValue(hAccountKey
,
540 (LPVOID
)&EmptyNtHash
,
541 sizeof(ENCRYPTED_NT_OWF_PASSWORD
));
542 if (!NT_SUCCESS(Status
))
545 /* Set LMPwdHistory attribute*/
546 Status
= SampRegSetValue(hAccountKey
,
551 if (!NT_SUCCESS(Status
))
554 /* Set NTPwdHistory attribute*/
555 Status
= SampRegSetValue(hAccountKey
,
560 if (!NT_SUCCESS(Status
))
563 /* Set PrivateData attribute*/
564 Status
= SampRegSetValue(hAccountKey
,
567 (LPVOID
)lpEmptyString
,
569 if (!NT_SUCCESS(Status
))
572 /* Set the SecDesc attribute*/
573 Status
= SampRegSetValue(hAccountKey
,
578 if (!NT_SUCCESS(Status
))
581 Status
= SampRegOpenKey(hDomainKey
,
585 if (!NT_SUCCESS(Status
))
588 Status
= SampRegSetValue(hNamesKey
,
591 (LPVOID
)&ulRelativeId
,
595 SampRegCloseKey(&hNamesKey
);
598 RtlFreeHeap(RtlGetProcessHeap(), 0, Sd
);
601 RtlFreeHeap(RtlGetProcessHeap(), 0, UserSid
);
603 if (hAccountKey
!= NULL
)
605 SampRegCloseKey(&hAccountKey
);
607 if (!NT_SUCCESS(Status
))
608 SampRegDeleteKey(hDomainKey
,
618 SampSetupCreateDomain(IN HANDLE hServerKey
,
619 IN LPCWSTR lpKeyName
,
620 IN LPCWSTR lpDomainName
,
622 IN BOOLEAN bBuiltinDomain
,
623 OUT HANDLE
*lpDomainKey
)
625 SAM_DOMAIN_FIXED_DATA FixedData
;
626 WCHAR szDomainKeyName
[32];
627 LPWSTR lpEmptyString
= L
"";
628 HANDLE hDomainKey
= NULL
;
629 HANDLE hAliasesKey
= NULL
;
630 HANDLE hGroupsKey
= NULL
;
631 HANDLE hUsersKey
= NULL
;
632 HANDLE hNamesKey
= NULL
;
633 PSECURITY_DESCRIPTOR Sd
= NULL
;
637 if (lpDomainKey
!= NULL
)
640 /* Initialize the fixed domain data */
641 memset(&FixedData
, 0, sizeof(SAM_DOMAIN_FIXED_DATA
));
642 FixedData
.Version
= 1;
643 NtQuerySystemTime(&FixedData
.CreationTime
);
644 FixedData
.DomainModifiedCount
.QuadPart
= 0;
645 FixedData
.MaxPasswordAge
.QuadPart
= -(6LL * 7LL * 24LL * 60LL * 60LL * TICKS_PER_SECOND
); /* 6 weeks */
646 FixedData
.MinPasswordAge
.QuadPart
= 0; /* right now */
647 FixedData
.ForceLogoff
.QuadPart
= LLONG_MAX
; /* very far in the future aka never */
648 FixedData
.LockoutDuration
.QuadPart
= -(30LL * 60LL * TICKS_PER_SECOND
); /* 30 minutes */
649 FixedData
.LockoutObservationWindow
.QuadPart
= -(30LL * 60LL * TICKS_PER_SECOND
); /* 30 minutes */
650 FixedData
.ModifiedCountAtLastPromotion
.QuadPart
= 0;
651 FixedData
.NextRid
= 1000;
652 FixedData
.PasswordProperties
= 0;
653 FixedData
.MinPasswordLength
= 0;
654 FixedData
.PasswordHistoryLength
= 0;
655 FixedData
.LockoutThreshold
= 0;
656 FixedData
.DomainServerState
= DomainServerEnabled
;
657 FixedData
.DomainServerRole
= DomainServerRolePrimary
;
658 FixedData
.UasCompatibilityRequired
= TRUE
;
660 wcscpy(szDomainKeyName
, L
"Domains\\");
661 wcscat(szDomainKeyName
, lpKeyName
);
663 Status
= SampRegCreateKey(hServerKey
,
667 if (!NT_SUCCESS(Status
))
670 /* Set the fixed data value */
671 Status
= SampRegSetValue(hDomainKey
,
675 sizeof(SAM_DOMAIN_FIXED_DATA
));
676 if (!NT_SUCCESS(Status
))
679 if (lpDomainSid
!= NULL
)
681 Status
= SampRegSetValue(hDomainKey
,
684 (LPVOID
)lpDomainName
,
685 (wcslen(lpDomainName
) + 1) * sizeof(WCHAR
));
686 if (!NT_SUCCESS(Status
))
689 Status
= SampRegSetValue(hDomainKey
,
693 RtlLengthSid(lpDomainSid
));
694 if (!NT_SUCCESS(Status
))
698 Status
= SampRegSetValue(hDomainKey
,
701 (LPVOID
)lpEmptyString
,
703 if (!NT_SUCCESS(Status
))
706 Status
= SampRegSetValue(hDomainKey
,
707 L
"ReplicaSourceNodeName",
709 (LPVOID
)lpEmptyString
,
711 if (!NT_SUCCESS(Status
))
714 /* Create the Alias container */
715 Status
= SampRegCreateKey(hDomainKey
,
719 if (!NT_SUCCESS(Status
))
722 Status
= SampRegCreateKey(hAliasesKey
,
726 if (!NT_SUCCESS(Status
))
729 SampRegCloseKey(&hNamesKey
);
731 /* Create the Groups container */
732 Status
= SampRegCreateKey(hDomainKey
,
736 if (!NT_SUCCESS(Status
))
739 Status
= SampRegCreateKey(hGroupsKey
,
743 if (!NT_SUCCESS(Status
))
746 SampRegCloseKey(&hNamesKey
);
748 /* Create the Users container */
749 Status
= SampRegCreateKey(hDomainKey
,
753 if (!NT_SUCCESS(Status
))
756 Status
= SampRegCreateKey(hUsersKey
,
760 if (!NT_SUCCESS(Status
))
763 /* Create the server SD */
764 if (bBuiltinDomain
!= FALSE
)
765 Status
= SampCreateBuiltinDomainSD(&Sd
,
768 Status
= SampCreateAccountDomainSD(&Sd
,
771 if (!NT_SUCCESS(Status
))
774 /* Set SecDesc attribute*/
775 Status
= SampRegSetValue(hServerKey
,
780 if (!NT_SUCCESS(Status
))
783 SampRegCloseKey(&hNamesKey
);
785 if (lpDomainKey
!= NULL
)
786 *lpDomainKey
= hDomainKey
;
790 RtlFreeHeap(RtlGetProcessHeap(), 0, Sd
);
792 SampRegCloseKey(&hAliasesKey
);
793 SampRegCloseKey(&hGroupsKey
);
794 SampRegCloseKey(&hUsersKey
);
796 if (!NT_SUCCESS(Status
))
797 SampRegCloseKey(&hDomainKey
);
805 SampSetupCreateServer(IN HANDLE hSamKey
,
806 OUT HANDLE
*lpServerKey
)
808 HANDLE hServerKey
= NULL
;
809 HANDLE hDomainsKey
= NULL
;
810 PSECURITY_DESCRIPTOR Sd
= NULL
;
814 Status
= SampRegCreateKey(hSamKey
,
818 if (!NT_SUCCESS(Status
))
821 Status
= SampRegCreateKey(hServerKey
,
825 if (!NT_SUCCESS(Status
))
828 /* Create the server SD */
829 Status
= SampCreateServerSD(&Sd
,
831 if (!NT_SUCCESS(Status
))
834 /* Set SecDesc attribute*/
835 Status
= SampRegSetValue(hServerKey
,
840 if (!NT_SUCCESS(Status
))
843 SampRegCloseKey(&hDomainsKey
);
845 *lpServerKey
= hServerKey
;
849 RtlFreeHeap(RtlGetProcessHeap(), 0, Sd
);
856 SampGetAccountDomainInfo(PPOLICY_ACCOUNT_DOMAIN_INFO
*AccountDomainInfo
)
858 LSA_OBJECT_ATTRIBUTES ObjectAttributes
;
859 LSA_HANDLE PolicyHandle
;
862 TRACE("SampGetAccountDomainInfo\n");
864 memset(&ObjectAttributes
, 0, sizeof(LSA_OBJECT_ATTRIBUTES
));
865 ObjectAttributes
.Length
= sizeof(LSA_OBJECT_ATTRIBUTES
);
867 Status
= LsaOpenPolicy(NULL
,
869 POLICY_VIEW_LOCAL_INFORMATION
,
871 if (Status
!= STATUS_SUCCESS
)
873 ERR("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status
);
877 Status
= LsaQueryInformationPolicy(PolicyHandle
,
878 PolicyAccountDomainInformation
,
879 (PVOID
*)AccountDomainInfo
);
881 LsaClose(PolicyHandle
);
888 SampInitializeSAM(VOID
)
890 PPOLICY_ACCOUNT_DOMAIN_INFO AccountDomainInfo
= NULL
;
891 HANDLE hSamKey
= NULL
;
892 HANDLE hServerKey
= NULL
;
893 HANDLE hBuiltinDomainKey
= NULL
;
894 HANDLE hAccountDomainKey
= NULL
;
895 PSID pBuiltinSid
= NULL
;
896 PSID pInteractiveSid
= NULL
;
897 PSID pAuthenticatedUserSid
= NULL
;
901 WCHAR szComment
[256];
905 TRACE("SampInitializeSAM() called\n");
907 hInstance
= GetModuleHandleW(L
"samsrv.dll");
909 /* Open the SAM key */
910 Status
= SampRegOpenKey(NULL
,
911 L
"\\Registry\\Machine\\SAM",
912 KEY_READ
| KEY_CREATE_SUB_KEY
| KEY_ENUMERATE_SUB_KEYS
,
914 if (!NT_SUCCESS(Status
))
916 ERR("Failed to open the SAM key (Status: 0x%08lx)\n", Status
);
920 /* Create the SAM Server object */
921 Status
= SampSetupCreateServer(hSamKey
,
923 if (!NT_SUCCESS(Status
))
929 /* Create and initialize the Builtin Domain SID */
930 pBuiltinSid
= RtlAllocateHeap(RtlGetProcessHeap(), 0, RtlLengthRequiredSid(1));
931 if (pBuiltinSid
== NULL
)
933 ERR("Failed to allocate the Builtin Domain SID\n");
938 RtlInitializeSid(pBuiltinSid
, &SecurityNtAuthority
, 1);
939 *(RtlSubAuthoritySid(pBuiltinSid
, 0)) = SECURITY_BUILTIN_DOMAIN_RID
;
941 /* Create and initialize the Interactive SID */
942 pInteractiveSid
= RtlAllocateHeap(RtlGetProcessHeap(), 0, RtlLengthRequiredSid(1));
943 if (pInteractiveSid
== NULL
)
945 ERR("Failed to allocate the Interactive SID\n");
950 RtlInitializeSid(pInteractiveSid
, &SecurityNtAuthority
, 1);
951 *(RtlSubAuthoritySid(pInteractiveSid
, 0)) = SECURITY_INTERACTIVE_RID
;
953 /* Create and initialize the Authenticated User SID */
954 pAuthenticatedUserSid
= RtlAllocateHeap(RtlGetProcessHeap(), 0, RtlLengthRequiredSid(1));
955 if (pAuthenticatedUserSid
== NULL
)
957 ERR("Failed to allocate the Authenticated User SID\n");
962 RtlInitializeSid(pAuthenticatedUserSid
, &SecurityNtAuthority
, 1);
963 *(RtlSubAuthoritySid(pAuthenticatedUserSid
, 0)) = SECURITY_AUTHENTICATED_USER_RID
;
965 /* Get account domain information */
966 Status
= SampGetAccountDomainInfo(&AccountDomainInfo
);
967 if (!NT_SUCCESS(Status
))
969 ERR("SampGetAccountDomainInfo failed (Status %08lx)\n", Status
);
974 SampLoadString(hInstance
, IDS_DOMAIN_BUILTIN_NAME
, szName
, 80);
976 /* Create the Builtin domain */
977 Status
= SampSetupCreateDomain(hServerKey
,
983 if (!NT_SUCCESS(Status
))
989 SampLoadString(hInstance
, IDS_ALIAS_ADMINISTRATORS_NAME
, szName
, 80);
990 SampLoadString(hInstance
, IDS_ALIAS_ADMINISTRATORS_COMMENT
, szComment
, 256);
992 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
995 DOMAIN_ALIAS_RID_ADMINS
);
997 SampLoadString(hInstance
, IDS_ALIAS_USERS_NAME
, szName
, 80);
998 SampLoadString(hInstance
, IDS_ALIAS_USERS_COMMENT
, szComment
, 256);
1000 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
1003 DOMAIN_ALIAS_RID_USERS
);
1005 SampLoadString(hInstance
, IDS_ALIAS_GUESTS_NAME
, szName
, 80);
1006 SampLoadString(hInstance
, IDS_ALIAS_GUESTS_COMMENT
, szComment
, 256);
1008 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
1011 DOMAIN_ALIAS_RID_GUESTS
);
1013 SampLoadString(hInstance
, IDS_ALIAS_POWER_USERS_NAME
, szName
, 80);
1014 SampLoadString(hInstance
, IDS_ALIAS_POWER_USERS_COMMENT
, szComment
, 256);
1016 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
1019 DOMAIN_ALIAS_RID_POWER_USERS
);
1021 /* Add the Administrator user to the Administrators alias */
1022 pSid
= AppendRidToSid(AccountDomainInfo
->DomainSid
,
1023 DOMAIN_USER_RID_ADMIN
);
1026 SampSetupAddMemberToAlias(hBuiltinDomainKey
,
1027 DOMAIN_ALIAS_RID_ADMINS
,
1030 RtlFreeHeap(RtlGetProcessHeap(), 0, pSid
);
1033 /* Add the Guest user to the Guests alias */
1034 pSid
= AppendRidToSid(AccountDomainInfo
->DomainSid
,
1035 DOMAIN_USER_RID_GUEST
);
1038 SampSetupAddMemberToAlias(hBuiltinDomainKey
,
1039 DOMAIN_ALIAS_RID_GUESTS
,
1042 RtlFreeHeap(RtlGetProcessHeap(), 0, pSid
);
1045 /* Add the Interactive SID to the Users alias */
1046 SampSetupAddMemberToAlias(hBuiltinDomainKey
,
1047 DOMAIN_ALIAS_RID_USERS
,
1050 /* Add the Authenticated User SID to the Users alias */
1051 SampSetupAddMemberToAlias(hBuiltinDomainKey
,
1052 DOMAIN_ALIAS_RID_USERS
,
1053 pAuthenticatedUserSid
);
1055 /* Create the Account domain */
1056 Status
= SampSetupCreateDomain(hServerKey
,
1059 AccountDomainInfo
->DomainSid
,
1061 &hAccountDomainKey
);
1062 if (!NT_SUCCESS(Status
))
1068 SampLoadString(hInstance
, IDS_GROUP_NONE_NAME
, szName
, 80);
1069 SampLoadString(hInstance
, IDS_GROUP_NONE_COMMENT
, szComment
, 256);
1071 SampSetupCreateGroupAccount(hAccountDomainKey
,
1074 DOMAIN_GROUP_RID_USERS
);
1076 SampLoadString(hInstance
, IDS_USER_ADMINISTRATOR_NAME
, szName
, 80);
1077 SampLoadString(hInstance
, IDS_USER_ADMINISTRATOR_COMMENT
, szComment
, 256);
1079 SampSetupCreateUserAccount(hAccountDomainKey
,
1082 AccountDomainInfo
->DomainSid
,
1083 DOMAIN_USER_RID_ADMIN
,
1084 USER_DONT_EXPIRE_PASSWORD
| USER_NORMAL_ACCOUNT
);
1086 SampSetupAddMemberToGroup(hAccountDomainKey
,
1087 DOMAIN_GROUP_RID_USERS
,
1088 DOMAIN_USER_RID_ADMIN
);
1090 SampLoadString(hInstance
, IDS_USER_GUEST_NAME
, szName
, 80);
1091 SampLoadString(hInstance
, IDS_USER_GUEST_COMMENT
, szComment
, 256);
1093 SampSetupCreateUserAccount(hAccountDomainKey
,
1096 AccountDomainInfo
->DomainSid
,
1097 DOMAIN_USER_RID_GUEST
,
1098 USER_ACCOUNT_DISABLED
| USER_DONT_EXPIRE_PASSWORD
| USER_NORMAL_ACCOUNT
);
1100 SampSetupAddMemberToGroup(hAccountDomainKey
,
1101 DOMAIN_GROUP_RID_USERS
,
1102 DOMAIN_USER_RID_GUEST
);
1105 if (AccountDomainInfo
)
1106 LsaFreeMemory(AccountDomainInfo
);
1108 if (pAuthenticatedUserSid
)
1109 RtlFreeHeap(RtlGetProcessHeap(), 0, pAuthenticatedUserSid
);
1111 if (pInteractiveSid
)
1112 RtlFreeHeap(RtlGetProcessHeap(), 0, pInteractiveSid
);
1115 RtlFreeHeap(RtlGetProcessHeap(), 0, pBuiltinSid
);
1117 SampRegCloseKey(&hAccountDomainKey
);
1118 SampRegCloseKey(&hBuiltinDomainKey
);
1119 SampRegCloseKey(&hServerKey
);
1120 SampRegCloseKey(&hSamKey
);
1122 TRACE("SampInitializeSAM() done\n");