18#define TICKS_PER_SECOND 10000000LL
36 swprintf(szKeyName,
L"Aliases\\%08lX\\Members", AliasId);
58 swprintf(szKeyName,
L"Aliases\\Members\\%s", MemberSidString);
82 if (MemberSidString !=
NULL)
96 WCHAR szAccountKeyName[32];
103 swprintf(szAccountKeyName,
L"Aliases\\%08lX", ulRelativeId);
162 if (hAccountKey !=
NULL)
181 WCHAR szKeyName[256];
184 ULONG MembersCount = 0;
189 swprintf(szKeyName,
L"Groups\\%08lX", GroupId);
207 if (MembersBuffer ==
NULL)
226 for (
i = 0;
i < MembersCount;
i++)
228 if (MembersBuffer[
i] == MemberId)
235 MembersBuffer[MembersCount] = MemberId;
245 if (MembersBuffer !=
NULL)
262 WCHAR szAccountKeyName[32];
272 FixedGroupData.
GroupId = ulRelativeId;
275 swprintf(szAccountKeyName,
L"Groups\\%08lX", ulRelativeId);
342 if (hAccountKey !=
NULL)
362 ULONG UserAccountControl)
366 UCHAR LogonHours[23];
368 WCHAR szAccountKeyName[32];
394 FixedUserData.
UserId = ulRelativeId;
404 swprintf(szAccountKeyName,
L"Users\\%08lX", ulRelativeId);
446 L"HomeDirectoryDrive",
503 memset(&(LogonHours[2]), 0xff, 21);
603 if (hAccountKey !=
NULL)
626 WCHAR szDomainKeyName[32];
637 if (lpDomainKey !=
NULL)
660 wcscpy(szDomainKeyName,
L"Domains\\");
661 wcscat(szDomainKeyName, lpKeyName);
679 if (lpDomainSid !=
NULL)
707 L"ReplicaSourceNodeName",
764 if (bBuiltinDomain !=
FALSE)
785 if (lpDomainKey !=
NULL)
786 *lpDomainKey = hDomainKey;
845 *lpServerKey = hServerKey;
862 TRACE(
"SampGetAccountDomainInfo\n");
873 ERR(
"LsaOpenPolicy failed (Status: 0x%08lx)\n",
Status);
879 (
PVOID *)AccountDomainInfo);
905 TRACE(
"SampInitializeSAM() called\n");
911 L"\\Registry\\Machine\\SAM",
916 ERR(
"Failed to open the SAM key (Status: 0x%08lx)\n",
Status);
931 if (pBuiltinSid ==
NULL)
933 ERR(
"Failed to allocate the Builtin Domain SID\n");
943 if (pInteractiveSid ==
NULL)
945 ERR(
"Failed to allocate the Interactive SID\n");
957 ERR(
"Failed to allocate the Authenticated User SID\n");
969 ERR(
"SampGetAccountDomainInfo failed (Status %08lx)\n",
Status);
1134 &hAccountDomainKey);
1183 if (AccountDomainInfo)
1189 if (pInteractiveSid)
1190 RtlFreeHeap(RtlGetProcessHeap(), 0, pInteractiveSid);
1200 TRACE(
"SampInitializeSAM() done\n");
static PSID pAuthenticatedUserSid
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define RegCloseKey(hKey)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
NTSTATUS WINAPI LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PVOID *Buffer)
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
BOOL WINAPI ConvertSidToStringSidW(PSID Sid, LPWSTR *StringSid)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
NTSTATUS SampRegQueryValue(IN HANDLE KeyHandle, IN LPCWSTR ValueName, OUT PULONG Type OPTIONAL, OUT PVOID Data OPTIONAL, IN OUT PULONG DataLength OPTIONAL)
NTSTATUS SampRegCloseKey(IN OUT PHANDLE KeyHandle)
NTSTATUS SampRegSetValue(HANDLE KeyHandle, LPCWSTR ValueName, ULONG Type, LPVOID Data, ULONG DataLength)
NTSTATUS SampRegDeleteKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName)
NTSTATUS SampRegOpenKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle)
NTSTATUS SampRegCreateKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle)
#define IDS_ALIAS_REPLICATOR_COMMENT
#define IDS_ALIAS_ADMINISTRATORS_COMMENT
#define IDS_ALIAS_USERS_COMMENT
#define IDS_ALIAS_BACKUP_OPS_COMMENT
#define IDS_ALIAS_REPLICATOR_NAME
#define IDS_ALIAS_NETWORK_CONFIGURATION_OPS_NAME
#define IDS_ALIAS_POWER_USERS_NAME
#define IDS_ALIAS_USERS_NAME
#define IDS_ALIAS_LOGGING_USERS_COMMENT
#define IDS_ALIAS_ADMINISTRATORS_NAME
#define IDS_ALIAS_LOGGING_USERS_NAME
#define IDS_ALIAS_PRINT_OPS_NAME
#define IDS_USER_ADMINISTRATOR_NAME
#define IDS_ALIAS_GUESTS_COMMENT
#define IDS_USER_GUEST_COMMENT
#define IDS_ALIAS_MONITORING_USERS_NAME
#define IDS_ALIAS_BACKUP_OPS_NAME
#define IDS_ALIAS_POWER_USERS_COMMENT
#define IDS_ALIAS_PRINT_OPS_COMMENT
#define IDS_USER_ADMINISTRATOR_COMMENT
#define IDS_ALIAS_NETWORK_CONFIGURATION_OPS_COMMENT
#define IDS_GROUP_NONE_COMMENT
#define IDS_ALIAS_GUESTS_NAME
#define IDS_ALIAS_MONITORING_USERS_COMMENT
#define IDS_ALIAS_REMOTE_DESKTOP_USERS_COMMENT
#define IDS_USER_GUEST_NAME
#define IDS_ALIAS_REMOTE_DESKTOP_USERS_NAME
#define IDS_DOMAIN_BUILTIN_NAME
#define IDS_GROUP_NONE_NAME
NTSTATUS SampCreateGroupSD(OUT PSECURITY_DESCRIPTOR *GroupSd, OUT PULONG Size)
NTSTATUS SampCreateAccountDomainSD(OUT PSECURITY_DESCRIPTOR *DomainSd, OUT PULONG Size)
NTSTATUS SampCreateBuiltinDomainSD(OUT PSECURITY_DESCRIPTOR *DomainSd, OUT PULONG Size)
NTSTATUS SampCreateServerSD(OUT PSECURITY_DESCRIPTOR *ServerSd, OUT PULONG Size)
NTSTATUS SampCreateAliasSD(OUT PSECURITY_DESCRIPTOR *AliasSd, OUT PULONG Size)
NTSTATUS SampCreateUserSD(IN PSID UserSid, OUT PSECURITY_DESCRIPTOR *UserSd, OUT PULONG Size)
INT SampLoadString(HINSTANCE hInstance, UINT uId, LPWSTR lpBuffer, INT nBufferMax)
static NTSTATUS SampSetupCreateDomain(IN HANDLE hServerKey, IN LPCWSTR lpKeyName, IN LPCWSTR lpDomainName, IN PSID lpDomainSid, IN BOOLEAN bBuiltinDomain, OUT HANDLE *lpDomainKey)
static NTSTATUS SampSetupCreateServer(IN HANDLE hSamKey, OUT HANDLE *lpServerKey)
static NTSTATUS SampSetupCreateGroupAccount(HANDLE hDomainKey, LPCWSTR lpAccountName, LPCWSTR lpComment, ULONG ulRelativeId)
static NTSTATUS SampSetupCreateAliasAccount(HANDLE hDomainKey, LPCWSTR lpAccountName, LPCWSTR lpDescription, ULONG ulRelativeId)
NTSTATUS SampGetAccountDomainInfo(PPOLICY_ACCOUNT_DOMAIN_INFO *AccountDomainInfo)
static NTSTATUS SampSetupAddMemberToGroup(IN HANDLE hDomainKey, IN ULONG GroupId, IN ULONG MemberId)
static BOOL SampSetupAddMemberToAlias(HKEY hDomainKey, ULONG AliasId, PSID MemberSid)
SID_IDENTIFIER_AUTHORITY SecurityNtAuthority
BOOL SampInitializeSAM(VOID)
static NTSTATUS SampSetupCreateUserAccount(HANDLE hDomainKey, LPCWSTR lpAccountName, LPCWSTR lpComment, PSID lpDomainSid, ULONG ulRelativeId, ULONG UserAccountControl)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
HLOCAL NTAPI LocalFree(HLOCAL hMem)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static const WCHAR szComment[]
static PSID AppendRidToSid(PSID SrcSid, ULONG Rid)
NTSYSAPI PULONG NTAPI RtlSubAuthoritySid(_In_ PSID Sid, _In_ ULONG SubAuthority)
NTSYSAPI ULONG NTAPI RtlLengthRequiredSid(IN ULONG SubAuthorityCount)
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
#define SE_GROUP_MANDATORY
#define SE_GROUP_ENABLED_BY_DEFAULT
#define KEY_CREATE_SUB_KEY
#define REG_OPTION_NON_VOLATILE
#define KEY_ENUMERATE_SUB_KEYS
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSYSAPI NTSTATUS NTAPI RtlInitializeSid(IN OUT PSID Sid, IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount)
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
#define USER_NORMAL_ACCOUNT
@ DomainServerRolePrimary
#define USER_DONT_EXPIRE_PASSWORD
#define USER_ACCOUNT_DISABLED
@ PolicyAccountDomainInformation
struct _LSA_OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES
#define POLICY_VIEW_LOCAL_INFORMATION
#define STATUS_MEMBER_IN_GROUP
static const WCHAR szName[]
ENCRYPTED_LM_OWF_PASSWORD EmptyLmHash
ENCRYPTED_NT_OWF_PASSWORD EmptyNtHash
NT_PRODUCT_TYPE SampProductType
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define midl_user_allocate
DOMAIN_SERVER_ENABLE_STATE DomainServerState
LARGE_INTEGER CreationTime
USHORT PasswordHistoryLength
LARGE_INTEGER LockoutObservationWindow
DOMAIN_SERVER_ROLE DomainServerRole
LARGE_INTEGER MaxPasswordAge
LARGE_INTEGER LockoutDuration
BOOLEAN UasCompatibilityRequired
LARGE_INTEGER ModifiedCountAtLastPromotion
LARGE_INTEGER MinPasswordAge
LARGE_INTEGER DomainModifiedCount
LARGE_INTEGER ForceLogoff
LARGE_INTEGER LastBadPasswordTime
LARGE_INTEGER AccountExpires
LARGE_INTEGER PasswordLastSet
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
_In_ LPCSTR lpAccountName
#define DOMAIN_ALIAS_RID_USERS
#define DOMAIN_ALIAS_RID_GUESTS
#define DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS
#define SECURITY_BUILTIN_DOMAIN_RID
#define DOMAIN_USER_RID_ADMIN
#define SECURITY_INTERACTIVE_RID
#define DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS
#define DOMAIN_ALIAS_RID_MONITORING_USERS
#define SECURITY_AUTHENTICATED_USER_RID
#define DOMAIN_ALIAS_RID_LOGGING_USERS
#define DOMAIN_USER_RID_GUEST
#define SECURITY_NT_AUTHORITY
#define DOMAIN_ALIAS_RID_BACKUP_OPS
#define DOMAIN_ALIAS_RID_PRINT_OPS
#define DOMAIN_ALIAS_RID_REPLICATOR
#define DOMAIN_ALIAS_RID_POWER_USERS
#define DOMAIN_ALIAS_RID_ADMINS
#define DOMAIN_GROUP_RID_USERS