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
10 /* INCLUDES ****************************************************************/
14 WINE_DEFAULT_DEBUG_CHANNEL(samsrv
);
17 /* GLOBALS *****************************************************************/
19 #define TICKS_PER_SECOND 10000000LL
21 SID_IDENTIFIER_AUTHORITY SecurityNtAuthority
= {SECURITY_NT_AUTHORITY
};
24 /* FUNCTIONS ***************************************************************/
27 SampSetupAddMemberToAlias(HKEY hDomainKey
,
32 LPWSTR MemberSidString
= NULL
;
36 ConvertSidToStringSidW(MemberSid
, &MemberSidString
);
38 swprintf(szKeyName
, L
"Aliases\\%08lX\\Members", AliasId
);
40 if (!RegCreateKeyExW(hDomainKey
,
44 REG_OPTION_NON_VOLATILE
,
50 RegSetValueEx(hMembersKey
,
55 RtlLengthSid(MemberSid
));
57 RegCloseKey(hMembersKey
);
60 swprintf(szKeyName
, L
"Aliases\\Members\\%s", MemberSidString
);
62 if (!RegCreateKeyExW(hDomainKey
,
66 REG_OPTION_NON_VOLATILE
,
72 swprintf(szKeyName
, L
"%08lX", AliasId
);
74 RegSetValueEx(hMembersKey
,
79 RtlLengthSid(MemberSid
));
81 RegCloseKey(hMembersKey
);
84 if (MemberSidString
!= NULL
)
85 LocalFree(MemberSidString
);
93 SampSetupCreateAliasAccount(HANDLE hDomainKey
,
94 LPCWSTR lpAccountName
,
95 LPCWSTR lpDescription
,
98 WCHAR szAccountKeyName
[32];
99 HANDLE hAccountKey
= NULL
;
100 HANDLE hNamesKey
= 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
))
129 Status
= SampRegOpenKey(hDomainKey
,
133 if (!NT_SUCCESS(Status
))
136 Status
= SampRegSetValue(hNamesKey
,
139 (LPVOID
)&ulRelativeId
,
143 if (hNamesKey
!= NULL
)
144 SampRegCloseKey(hNamesKey
);
146 if (hAccountKey
!= NULL
)
148 SampRegCloseKey(hAccountKey
);
150 if (!NT_SUCCESS(Status
))
151 SampRegDeleteKey(hDomainKey
,
161 SampSetupAddMemberToGroup(IN HANDLE hDomainKey
,
165 WCHAR szKeyName
[256];
166 HANDLE hGroupKey
= NULL
;
167 PULONG MembersBuffer
= NULL
;
168 ULONG MembersCount
= 0;
173 swprintf(szKeyName
, L
"Groups\\%08lX", GroupId
);
175 Status
= SampRegOpenKey(hDomainKey
,
179 if (!NT_SUCCESS(Status
))
182 Status
= SampRegQueryValue(hGroupKey
,
187 if (!NT_SUCCESS(Status
) && Status
!= STATUS_OBJECT_NAME_NOT_FOUND
)
190 MembersBuffer
= midl_user_allocate(Length
+ sizeof(ULONG
));
191 if (MembersBuffer
== NULL
)
193 Status
= STATUS_INSUFFICIENT_RESOURCES
;
197 if (Status
!= STATUS_OBJECT_NAME_NOT_FOUND
)
199 Status
= SampRegQueryValue(hGroupKey
,
204 if (!NT_SUCCESS(Status
))
207 MembersCount
= Length
/ sizeof(ULONG
);
210 for (i
= 0; i
< MembersCount
; i
++)
212 if (MembersBuffer
[i
] == MemberId
)
214 Status
= STATUS_MEMBER_IN_GROUP
;
219 MembersBuffer
[MembersCount
] = MemberId
;
220 Length
+= sizeof(ULONG
);
222 Status
= SampRegSetValue(hGroupKey
,
229 if (MembersBuffer
!= NULL
)
230 midl_user_free(MembersBuffer
);
232 if (hGroupKey
!= NULL
)
233 SampRegCloseKey(hGroupKey
);
241 SampSetupCreateGroupAccount(HANDLE hDomainKey
,
242 LPCWSTR lpAccountName
,
246 SAM_GROUP_FIXED_DATA FixedGroupData
;
247 WCHAR szAccountKeyName
[32];
248 HANDLE hAccountKey
= NULL
;
249 HANDLE hNamesKey
= NULL
;
252 /* Initialize fixed group data */
253 FixedGroupData
.Version
= 1;
254 FixedGroupData
.Reserved
= 0;
255 FixedGroupData
.GroupId
= ulRelativeId
;
256 FixedGroupData
.Attributes
= 0;
258 swprintf(szAccountKeyName
, L
"Groups\\%08lX", ulRelativeId
);
260 Status
= SampRegCreateKey(hDomainKey
,
264 if (!NT_SUCCESS(Status
))
267 Status
= SampRegSetValue(hAccountKey
,
270 (LPVOID
)&FixedGroupData
,
271 sizeof(SAM_GROUP_FIXED_DATA
));
272 if (!NT_SUCCESS(Status
))
275 Status
= SampRegSetValue(hAccountKey
,
278 (LPVOID
)lpAccountName
,
279 (wcslen(lpAccountName
) + 1) * sizeof(WCHAR
));
280 if (!NT_SUCCESS(Status
))
283 Status
= SampRegSetValue(hAccountKey
,
287 (wcslen(lpComment
) + 1) * sizeof(WCHAR
));
288 if (!NT_SUCCESS(Status
))
291 Status
= SampRegOpenKey(hDomainKey
,
295 if (!NT_SUCCESS(Status
))
298 Status
= SampRegSetValue(hNamesKey
,
301 (LPVOID
)&ulRelativeId
,
305 if (hNamesKey
!= NULL
)
306 SampRegCloseKey(hNamesKey
);
308 if (hAccountKey
!= NULL
)
310 SampRegCloseKey(hAccountKey
);
312 if (!NT_SUCCESS(Status
))
313 SampRegDeleteKey(hDomainKey
,
323 SampSetupCreateUserAccount(HANDLE hDomainKey
,
324 LPCWSTR lpAccountName
,
327 ULONG UserAccountControl
)
329 SAM_USER_FIXED_DATA FixedUserData
;
330 GROUP_MEMBERSHIP GroupMembership
;
331 UCHAR LogonHours
[23];
332 LPWSTR lpEmptyString
= L
"";
333 WCHAR szAccountKeyName
[32];
334 HANDLE hAccountKey
= NULL
;
335 HANDLE hNamesKey
= NULL
;
338 /* Initialize fixed user data */
339 FixedUserData
.Version
= 1;
340 FixedUserData
.Reserved
= 0;
341 FixedUserData
.LastLogon
.QuadPart
= 0;
342 FixedUserData
.LastLogoff
.QuadPart
= 0;
343 FixedUserData
.PasswordLastSet
.QuadPart
= 0;
344 FixedUserData
.AccountExpires
.LowPart
= MAXULONG
;
345 FixedUserData
.AccountExpires
.HighPart
= MAXLONG
;
346 FixedUserData
.LastBadPasswordTime
.QuadPart
= 0;
347 FixedUserData
.UserId
= ulRelativeId
;
348 FixedUserData
.PrimaryGroupId
= DOMAIN_GROUP_RID_USERS
;
349 FixedUserData
.UserAccountControl
= UserAccountControl
;
350 FixedUserData
.CountryCode
= 0;
351 FixedUserData
.CodePage
= 0;
352 FixedUserData
.BadPasswordCount
= 0;
353 FixedUserData
.LogonCount
= 0;
354 FixedUserData
.AdminCount
= 0;
355 FixedUserData
.OperatorCount
= 0;
357 swprintf(szAccountKeyName
, L
"Users\\%08lX", ulRelativeId
);
359 Status
= SampRegCreateKey(hDomainKey
,
363 if (!NT_SUCCESS(Status
))
366 Status
= SampRegSetValue(hAccountKey
,
369 (LPVOID
)&FixedUserData
,
370 sizeof(SAM_USER_FIXED_DATA
));
371 if (!NT_SUCCESS(Status
))
374 Status
= SampRegSetValue(hAccountKey
,
377 (LPVOID
)lpAccountName
,
378 (wcslen(lpAccountName
) + 1) * sizeof(WCHAR
));
379 if (!NT_SUCCESS(Status
))
382 Status
= SampRegSetValue(hAccountKey
,
385 (LPVOID
)lpEmptyString
,
387 if (!NT_SUCCESS(Status
))
390 Status
= SampRegSetValue(hAccountKey
,
393 (LPVOID
)lpEmptyString
,
395 if (!NT_SUCCESS(Status
))
398 Status
= SampRegSetValue(hAccountKey
,
399 L
"HomeDirectoryDrive",
401 (LPVOID
)lpEmptyString
,
403 if (!NT_SUCCESS(Status
))
406 Status
= SampRegSetValue(hAccountKey
,
409 (LPVOID
)lpEmptyString
,
411 if (!NT_SUCCESS(Status
))
414 Status
= SampRegSetValue(hAccountKey
,
417 (LPVOID
)lpEmptyString
,
419 if (!NT_SUCCESS(Status
))
422 Status
= SampRegSetValue(hAccountKey
,
426 (wcslen(lpComment
) + 1) * sizeof(WCHAR
));
427 if (!NT_SUCCESS(Status
))
430 Status
= SampRegSetValue(hAccountKey
,
433 (LPVOID
)lpEmptyString
,
435 if (!NT_SUCCESS(Status
))
438 Status
= SampRegSetValue(hAccountKey
,
441 (LPVOID
)lpEmptyString
,
443 if (!NT_SUCCESS(Status
))
446 Status
= SampRegSetValue(hAccountKey
,
449 (LPVOID
)lpEmptyString
,
451 if (!NT_SUCCESS(Status
))
454 /* Set LogonHours attribute*/
455 *((PUSHORT
)LogonHours
) = 168;
456 memset(&(LogonHours
[2]), 0xff, 21);
458 Status
= SampRegSetValue(hAccountKey
,
463 if (!NT_SUCCESS(Status
))
466 /* Set Groups attribute*/
467 GroupMembership
.RelativeId
= DOMAIN_GROUP_RID_USERS
;
468 GroupMembership
.Attributes
= SE_GROUP_MANDATORY
|
470 SE_GROUP_ENABLED_BY_DEFAULT
;
472 Status
= SampRegSetValue(hAccountKey
,
475 (LPVOID
)&GroupMembership
,
476 sizeof(GROUP_MEMBERSHIP
));
477 if (!NT_SUCCESS(Status
))
480 /* Set LMPwd attribute*/
481 Status
= SampRegSetValue(hAccountKey
,
484 (LPVOID
)&EmptyLmHash
,
485 sizeof(ENCRYPTED_LM_OWF_PASSWORD
));
486 if (!NT_SUCCESS(Status
))
489 /* Set NTPwd attribute*/
490 Status
= SampRegSetValue(hAccountKey
,
493 (LPVOID
)&EmptyNtHash
,
494 sizeof(ENCRYPTED_NT_OWF_PASSWORD
));
495 if (!NT_SUCCESS(Status
))
498 /* Set LMPwdHistory attribute*/
499 Status
= SampRegSetValue(hAccountKey
,
504 if (!NT_SUCCESS(Status
))
507 /* Set NTPwdHistory attribute*/
508 Status
= SampRegSetValue(hAccountKey
,
513 if (!NT_SUCCESS(Status
))
516 /* FIXME: Set SecDesc attribute*/
519 Status
= SampRegOpenKey(hDomainKey
,
523 if (!NT_SUCCESS(Status
))
526 Status
= SampRegSetValue(hNamesKey
,
529 (LPVOID
)&ulRelativeId
,
533 if (hNamesKey
!= NULL
)
534 SampRegCloseKey(hNamesKey
);
536 if (hAccountKey
!= NULL
)
538 SampRegCloseKey(hAccountKey
);
540 if (!NT_SUCCESS(Status
))
541 SampRegDeleteKey(hDomainKey
,
551 SampSetupCreateDomain(IN HANDLE hServerKey
,
552 IN LPCWSTR lpKeyName
,
553 IN LPCWSTR lpDomainName
,
555 OUT HANDLE
*lpDomainKey
)
557 SAM_DOMAIN_FIXED_DATA FixedData
;
558 WCHAR szDomainKeyName
[32];
559 LPWSTR lpEmptyString
= L
"";
560 HANDLE hDomainKey
= NULL
;
561 HANDLE hAliasesKey
= NULL
;
562 HANDLE hGroupsKey
= NULL
;
563 HANDLE hUsersKey
= NULL
;
564 HANDLE hNamesKey
= NULL
;
567 if (lpDomainKey
!= NULL
)
570 /* Initialize the fixed domain data */
571 memset(&FixedData
, 0, sizeof(SAM_DOMAIN_FIXED_DATA
));
572 FixedData
.Version
= 1;
573 NtQuerySystemTime(&FixedData
.CreationTime
);
574 FixedData
.DomainModifiedCount
.QuadPart
= 0;
575 FixedData
.MaxPasswordAge
.QuadPart
= -(6LL * 7LL * 24LL * 60LL * 60LL * TICKS_PER_SECOND
); /* 6 weeks */
576 FixedData
.MinPasswordAge
.QuadPart
= 0; /* right now */
577 // FixedData.ForceLogoff.QuadPart = // very far in the future aka never
578 FixedData
.LockoutDuration
.QuadPart
= -(30LL * 60LL * TICKS_PER_SECOND
); /* 30 minutes */
579 FixedData
.LockoutObservationWindow
.QuadPart
= -(30LL * 60LL * TICKS_PER_SECOND
); /* 30 minutes */
580 FixedData
.ModifiedCountAtLastPromotion
.QuadPart
= 0;
581 FixedData
.NextRid
= 1000;
582 FixedData
.PasswordProperties
= 0;
583 FixedData
.MinPasswordLength
= 0;
584 FixedData
.PasswordHistoryLength
= 0;
585 FixedData
.LockoutThreshold
= 0;
586 FixedData
.DomainServerState
= DomainServerEnabled
;
587 FixedData
.DomainServerRole
= DomainServerRolePrimary
;
588 FixedData
.UasCompatibilityRequired
= TRUE
;
590 wcscpy(szDomainKeyName
, L
"Domains\\");
591 wcscat(szDomainKeyName
, lpKeyName
);
593 Status
= SampRegCreateKey(hServerKey
,
597 if (!NT_SUCCESS(Status
))
600 /* Set the fixed data value */
601 Status
= SampRegSetValue(hDomainKey
,
605 sizeof(SAM_DOMAIN_FIXED_DATA
));
606 if (!NT_SUCCESS(Status
))
609 if (lpDomainSid
!= NULL
)
611 Status
= SampRegSetValue(hDomainKey
,
614 (LPVOID
)lpDomainName
,
615 (wcslen(lpDomainName
) + 1) * sizeof(WCHAR
));
616 if (!NT_SUCCESS(Status
))
619 Status
= SampRegSetValue(hDomainKey
,
623 RtlLengthSid(lpDomainSid
));
624 if (!NT_SUCCESS(Status
))
628 Status
= SampRegSetValue(hDomainKey
,
631 (LPVOID
)lpEmptyString
,
633 if (!NT_SUCCESS(Status
))
636 Status
= SampRegSetValue(hDomainKey
,
637 L
"ReplicaSourceNodeName",
639 (LPVOID
)lpEmptyString
,
641 if (!NT_SUCCESS(Status
))
644 /* Create the Alias container */
645 Status
= SampRegCreateKey(hDomainKey
,
649 if (!NT_SUCCESS(Status
))
652 Status
= SampRegCreateKey(hAliasesKey
,
656 if (!NT_SUCCESS(Status
))
659 SampRegCloseKey(hNamesKey
);
661 /* Create the Groups container */
662 Status
= SampRegCreateKey(hDomainKey
,
666 if (!NT_SUCCESS(Status
))
669 Status
= SampRegCreateKey(hGroupsKey
,
673 if (!NT_SUCCESS(Status
))
676 SampRegCloseKey(hNamesKey
);
678 /* Create the Users container */
679 Status
= SampRegCreateKey(hDomainKey
,
683 if (!NT_SUCCESS(Status
))
686 Status
= SampRegCreateKey(hUsersKey
,
690 if (!NT_SUCCESS(Status
))
693 SampRegCloseKey(hNamesKey
);
695 if (lpDomainKey
!= NULL
)
696 *lpDomainKey
= hDomainKey
;
699 if (hAliasesKey
!= NULL
)
700 SampRegCloseKey(hAliasesKey
);
702 if (hGroupsKey
!= NULL
)
703 SampRegCloseKey(hGroupsKey
);
705 if (hUsersKey
!= NULL
)
706 SampRegCloseKey(hUsersKey
);
708 if (!NT_SUCCESS(Status
))
710 if (hDomainKey
!= NULL
)
711 SampRegCloseKey(hDomainKey
);
720 SampSetupCreateServer(IN HANDLE hSamKey
,
721 OUT HANDLE
*lpServerKey
)
723 HANDLE hServerKey
= NULL
;
724 HANDLE hDomainsKey
= NULL
;
727 Status
= SampRegCreateKey(hSamKey
,
731 if (!NT_SUCCESS(Status
))
734 Status
= SampRegCreateKey(hServerKey
,
738 if (!NT_SUCCESS(Status
))
741 SampRegCloseKey(hDomainsKey
);
743 *lpServerKey
= hServerKey
;
752 SampGetAccountDomainInfo(PPOLICY_ACCOUNT_DOMAIN_INFO
*AccountDomainInfo
)
754 LSA_OBJECT_ATTRIBUTES ObjectAttributes
;
755 LSA_HANDLE PolicyHandle
;
758 TRACE("SampGetAccountDomainInfo\n");
760 memset(&ObjectAttributes
, 0, sizeof(LSA_OBJECT_ATTRIBUTES
));
761 ObjectAttributes
.Length
= sizeof(LSA_OBJECT_ATTRIBUTES
);
763 Status
= LsaOpenPolicy(NULL
,
765 POLICY_VIEW_LOCAL_INFORMATION
,
767 if (Status
!= STATUS_SUCCESS
)
769 ERR("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status
);
773 Status
= LsaQueryInformationPolicy(PolicyHandle
,
774 PolicyAccountDomainInformation
,
775 (PVOID
*)AccountDomainInfo
);
777 LsaClose(PolicyHandle
);
784 SampInitializeSAM(VOID
)
786 PPOLICY_ACCOUNT_DOMAIN_INFO AccountDomainInfo
= NULL
;
787 HANDLE hSamKey
= NULL
;
788 HANDLE hServerKey
= NULL
;
789 HANDLE hBuiltinDomainKey
= NULL
;
790 HANDLE hAccountDomainKey
= NULL
;
791 PSID pBuiltinSid
= NULL
;
795 WCHAR szComment
[256];
799 TRACE("SampInitializeSAM() called\n");
801 hInstance
= GetModuleHandleW(L
"samsrv.dll");
803 /* Open the SAM key */
804 Status
= SampRegOpenKey(NULL
,
805 L
"\\Registry\\Machine\\SAM",
806 KEY_READ
| KEY_CREATE_SUB_KEY
| KEY_ENUMERATE_SUB_KEYS
,
808 if (!NT_SUCCESS(Status
))
810 ERR("Failed to open the SAM key (Status: 0x%08lx)\n", Status
);
814 /* Create the SAM Server object */
815 Status
= SampSetupCreateServer(hSamKey
,
817 if (!NT_SUCCESS(Status
))
823 /* Create and initialize the Builtin Domain SID */
824 pBuiltinSid
= RtlAllocateHeap(RtlGetProcessHeap(), 0, RtlLengthRequiredSid(1));
825 if (pBuiltinSid
== NULL
)
827 ERR("Failed to alloacte the Builtin Domain SID\n");
832 RtlInitializeSid(pBuiltinSid
, &SecurityNtAuthority
, 1);
833 *(RtlSubAuthoritySid(pBuiltinSid
, 0)) = SECURITY_BUILTIN_DOMAIN_RID
;
835 /* Get account domain information */
836 Status
= SampGetAccountDomainInfo(&AccountDomainInfo
);
837 if (!NT_SUCCESS(Status
))
839 ERR("SampGetAccountDomainInfo failed (Status %08lx)\n", Status
);
844 SampLoadString(hInstance
, IDS_DOMAIN_BUILTIN_NAME
, szName
, 80);
846 /* Create the Builtin domain */
847 Status
= SampSetupCreateDomain(hServerKey
,
852 if (!NT_SUCCESS(Status
))
858 SampLoadString(hInstance
, IDS_ALIAS_ADMINISTRATORS_NAME
, szName
, 80);
859 SampLoadString(hInstance
, IDS_ALIAS_ADMINISTRATORS_COMMENT
, szComment
, 256);
861 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
864 DOMAIN_ALIAS_RID_ADMINS
);
866 SampLoadString(hInstance
, IDS_ALIAS_USERS_NAME
, szName
, 80);
867 SampLoadString(hInstance
, IDS_ALIAS_USERS_COMMENT
, szComment
, 256);
869 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
872 DOMAIN_ALIAS_RID_USERS
);
874 SampLoadString(hInstance
, IDS_ALIAS_GUESTS_NAME
, szName
, 80);
875 SampLoadString(hInstance
, IDS_ALIAS_GUESTS_COMMENT
, szComment
, 256);
877 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
880 DOMAIN_ALIAS_RID_GUESTS
);
882 SampLoadString(hInstance
, IDS_ALIAS_POWER_USERS_NAME
, szName
, 80);
883 SampLoadString(hInstance
, IDS_ALIAS_POWER_USERS_COMMENT
, szComment
, 256);
885 SampSetupCreateAliasAccount(hBuiltinDomainKey
,
888 DOMAIN_ALIAS_RID_POWER_USERS
);
890 /* Add the Administrator user to the Administrators alias */
891 pSid
= AppendRidToSid(AccountDomainInfo
->DomainSid
,
892 DOMAIN_USER_RID_ADMIN
);
895 SampSetupAddMemberToAlias(hBuiltinDomainKey
,
896 DOMAIN_ALIAS_RID_ADMINS
,
899 RtlFreeHeap(RtlGetProcessHeap(), 0, pSid
);
902 /* Add the Guest user to the Guests alias */
903 pSid
= AppendRidToSid(AccountDomainInfo
->DomainSid
,
904 DOMAIN_USER_RID_GUEST
);
907 SampSetupAddMemberToAlias(hBuiltinDomainKey
,
908 DOMAIN_ALIAS_RID_GUESTS
,
911 RtlFreeHeap(RtlGetProcessHeap(), 0, pSid
);
915 /* Create the Account domain */
916 Status
= SampSetupCreateDomain(hServerKey
,
919 AccountDomainInfo
->DomainSid
,
921 if (!NT_SUCCESS(Status
))
927 SampLoadString(hInstance
, IDS_GROUP_NONE_NAME
, szName
, 80);
928 SampLoadString(hInstance
, IDS_GROUP_NONE_COMMENT
, szComment
, 256);
930 SampSetupCreateGroupAccount(hAccountDomainKey
,
933 DOMAIN_GROUP_RID_USERS
);
935 SampLoadString(hInstance
, IDS_USER_ADMINISTRATOR_NAME
, szName
, 80);
936 SampLoadString(hInstance
, IDS_USER_ADMINISTRATOR_COMMENT
, szComment
, 256);
938 SampSetupCreateUserAccount(hAccountDomainKey
,
941 DOMAIN_USER_RID_ADMIN
,
942 USER_DONT_EXPIRE_PASSWORD
| USER_NORMAL_ACCOUNT
);
944 SampSetupAddMemberToGroup(hAccountDomainKey
,
945 DOMAIN_GROUP_RID_USERS
,
946 DOMAIN_USER_RID_ADMIN
);
948 SampLoadString(hInstance
, IDS_USER_GUEST_NAME
, szName
, 80);
949 SampLoadString(hInstance
, IDS_USER_GUEST_COMMENT
, szComment
, 256);
951 SampSetupCreateUserAccount(hAccountDomainKey
,
954 DOMAIN_USER_RID_GUEST
,
955 USER_ACCOUNT_DISABLED
| USER_DONT_EXPIRE_PASSWORD
| USER_NORMAL_ACCOUNT
);
957 SampSetupAddMemberToGroup(hAccountDomainKey
,
958 DOMAIN_GROUP_RID_USERS
,
959 DOMAIN_USER_RID_GUEST
);
962 if (AccountDomainInfo
)
963 LsaFreeMemory(AccountDomainInfo
);
966 RtlFreeHeap(RtlGetProcessHeap(), 0, pBuiltinSid
);
968 if (hAccountDomainKey
!= NULL
)
969 SampRegCloseKey(hAccountDomainKey
);
971 if (hBuiltinDomainKey
!= NULL
)
972 SampRegCloseKey(hBuiltinDomainKey
);
974 if (hServerKey
!= NULL
)
975 SampRegCloseKey(hServerKey
);
978 SampRegCloseKey(hSamKey
);
980 TRACE("SampInitializeSAM() done\n");