ReactOS  0.4.15-dev-1386-g5cb9f87
msv1_0.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _RPC_SID
 
struct  _RPC_UNICODE_STRING
 
struct  _OLD_LARGE_INTEGER
 
struct  RPC_SHORT_BLOB
 
struct  _SAMPR_SR_SECURITY_DESCRIPTOR
 
struct  _ENCRYPTED_LM_OWF_PASSWORD
 
struct  _SAMPR_ULONG_ARRAY
 
struct  _SAMPR_LOGON_HOURS
 
struct  _SAMPR_USER_INTERNAL2_INFORMATION
 
struct  _SAMPR_USER_ALL_INFORMATION
 
union  _SAMPR_USER_INFO_BUFFER
 
struct  _LSAPR_POLICY_AUDIT_EVENTS_INFO
 
struct  _LSAPR_POLICY_PRIMARY_DOM_INFO
 
struct  _LSAPR_POLICY_ACCOUNT_DOM_INFO
 
struct  _LSAPR_POLICY_PD_ACCOUNT_INFO
 
struct  _POLICY_LSA_REPLICA_SRCE_INFO
 
struct  _LSAPR_POLICY_DNS_DOMAIN_INFO
 
union  _LSAPR_POLICY_INFORMATION
 

Macros

#define FIXUP_POINTER(Pointer, Offset)   ((Pointer != NULL) ? ((PWSTR)((ULONG_PTR)Pointer + Offset)) : NULL)
 
#define USER_LOGON_BAD_PASSWORD   0x08000000
 
#define USER_LOGON_SUCCESS   0x10000000
 

Typedefs

typedef struct _RPC_SID RPC_SID
 
typedef struct _RPC_SIDPRPC_SID
 
typedef struct _RPC_UNICODE_STRING RPC_UNICODE_STRING
 
typedef struct _RPC_UNICODE_STRINGPRPC_UNICODE_STRING
 
typedef wchar_tPSAMPR_SERVER_NAME
 
typedef voidSAMPR_HANDLE
 
typedef struct _OLD_LARGE_INTEGER OLD_LARGE_INTEGER
 
typedef struct _OLD_LARGE_INTEGERPOLD_LARGE_INTEGER
 
typedef struct RPC_SHORT_BLOB RPC_SHORT_BLOB
 
typedef struct RPC_SHORT_BLOBPRPC_SHORT_BLOB
 
typedef struct _SAMPR_SR_SECURITY_DESCRIPTOR SAMPR_SR_SECURITY_DESCRIPTOR
 
typedef struct _SAMPR_SR_SECURITY_DESCRIPTORPSAMPR_SR_SECURITY_DESCRIPTOR
 
typedef struct _ENCRYPTED_LM_OWF_PASSWORD ENCRYPTED_LM_OWF_PASSWORD
 
typedef struct _ENCRYPTED_LM_OWF_PASSWORDPENCRYPTED_LM_OWF_PASSWORD
 
typedef struct _ENCRYPTED_LM_OWF_PASSWORD ENCRYPTED_NT_OWF_PASSWORD
 
typedef struct _ENCRYPTED_LM_OWF_PASSWORDPENCRYPTED_NT_OWF_PASSWORD
 
typedef struct _SAMPR_ULONG_ARRAY SAMPR_ULONG_ARRAY
 
typedef struct _SAMPR_ULONG_ARRAYPSAMPR_ULONG_ARRAY
 
typedef struct _SAMPR_LOGON_HOURS SAMPR_LOGON_HOURS
 
typedef struct _SAMPR_LOGON_HOURSPSAMPR_LOGON_HOURS
 
typedef struct _SAMPR_USER_INTERNAL2_INFORMATION SAMPR_USER_INTERNAL2_INFORMATION
 
typedef struct _SAMPR_USER_INTERNAL2_INFORMATIONPSAMPR_USER_INTERNAL2_INFORMATION
 
typedef struct _SAMPR_USER_ALL_INFORMATION SAMPR_USER_ALL_INFORMATION
 
typedef struct _SAMPR_USER_ALL_INFORMATIONPSAMPR_USER_ALL_INFORMATION
 
typedef union _SAMPR_USER_INFO_BUFFER SAMPR_USER_INFO_BUFFER
 
typedef union _SAMPR_USER_INFO_BUFFERPSAMPR_USER_INFO_BUFFER
 
typedef PVOID LSAPR_HANDLE
 
typedef struct _LSAPR_POLICY_AUDIT_EVENTS_INFO LSAPR_POLICY_AUDIT_EVENTS_INFO
 
typedef struct _LSAPR_POLICY_AUDIT_EVENTS_INFOPLSAPR_POLICY_AUDIT_EVENTS_INFO
 
typedef struct _LSAPR_POLICY_PRIMARY_DOM_INFO LSAPR_POLICY_PRIMARY_DOM_INFO
 
typedef struct _LSAPR_POLICY_PRIMARY_DOM_INFOPLSAPR_POLICY_PRIMARY_DOM_INFO
 
typedef struct _LSAPR_POLICY_ACCOUNT_DOM_INFO LSAPR_POLICY_ACCOUNT_DOM_INFO
 
typedef struct _LSAPR_POLICY_ACCOUNT_DOM_INFOPLSAPR_POLICY_ACCOUNT_DOM_INFO
 
typedef struct _LSAPR_POLICY_PD_ACCOUNT_INFO LSAPR_POLICY_PD_ACCOUNT_INFO
 
typedef struct _LSAPR_POLICY_PD_ACCOUNT_INFOPLSAPR_POLICY_PD_ACCOUNT_INFO
 
typedef struct _POLICY_LSA_REPLICA_SRCE_INFO POLICY_LSA_REPLICA_SRCE_INFO
 
typedef struct _POLICY_LSA_REPLICA_SRCE_INFOPPOLICY_LSA_REPLICA_SRCE_INFO
 
typedef struct _LSAPR_POLICY_DNS_DOMAIN_INFO LSAPR_POLICY_DNS_DOMAIN_INFO
 
typedef struct _LSAPR_POLICY_DNS_DOMAIN_INFOPLSAPR_POLICY_DNS_DOMAIN_INFO
 
typedef union _LSAPR_POLICY_INFORMATION LSAPR_POLICY_INFORMATION
 
typedef union _LSAPR_POLICY_INFORMATIONPLSAPR_POLICY_INFORMATION
 

Functions

NTSTATUS NTAPI SamIConnect (IN PSAMPR_SERVER_NAME ServerName, OUT SAMPR_HANDLE *ServerHandle, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Trusted)
 
VOID NTAPI SamIFreeVoid (PVOID Ptr)
 
VOID NTAPI SamIFree_SAMPR_ULONG_ARRAY (PSAMPR_ULONG_ARRAY Ptr)
 
VOID NTAPI SamIFree_SAMPR_USER_INFO_BUFFER (PSAMPR_USER_INFO_BUFFER Ptr, USER_INFORMATION_CLASS InformationClass)
 
NTSTATUS NTAPI SamrChangePasswordUser (IN SAMPR_HANDLE UserHandle, IN unsigned char LmPresent, IN PENCRYPTED_LM_OWF_PASSWORD OldLmEncryptedWithNewLm, IN PENCRYPTED_LM_OWF_PASSWORD NewLmEncryptedWithOldLm, IN unsigned char NtPresent, IN PENCRYPTED_NT_OWF_PASSWORD OldNtEncryptedWithNewNt, IN PENCRYPTED_NT_OWF_PASSWORD NewNtEncryptedWithOldNt, IN unsigned char NtCrossEncryptionPresent, IN PENCRYPTED_NT_OWF_PASSWORD NewNtEncryptedWithNewLm, IN unsigned char LmCrossEncryptionPresent, IN PENCRYPTED_LM_OWF_PASSWORD NewLmEncryptedWithNewNt)
 
NTSTATUS NTAPI SamrCloseHandle (IN OUT SAMPR_HANDLE *SamHandle)
 
NTSTATUS NTAPI SamrLookupDomainInSamServer (IN SAMPR_HANDLE ServerHandle, IN PRPC_UNICODE_STRING Name, OUT PRPC_SID *DomainId)
 
NTSTATUS NTAPI SamrLookupNamesInDomain (IN SAMPR_HANDLE DomainHandle, IN ULONG Count, IN RPC_UNICODE_STRING Names[], OUT PSAMPR_ULONG_ARRAY RelativeIds, OUT PSAMPR_ULONG_ARRAY Use)
 
NTSTATUS NTAPI SamrOpenDomain (IN SAMPR_HANDLE ServerHandle, IN ACCESS_MASK DesiredAccess, IN PRPC_SID DomainId, OUT SAMPR_HANDLE *DomainHandle)
 
NTSTATUS NTAPI SamrOpenUser (IN SAMPR_HANDLE DomainHandle, IN ACCESS_MASK DesiredAccess, IN ULONG UserId, OUT SAMPR_HANDLE *UserHandle)
 
NTSTATUS NTAPI SamrQueryInformationUser (IN SAMPR_HANDLE UserHandle, IN USER_INFORMATION_CLASS UserInformationClass, OUT PSAMPR_USER_INFO_BUFFER *Buffer)
 
NTSTATUS NTAPI SamrSetInformationUser (IN SAMPR_HANDLE UserHandle, IN USER_INFORMATION_CLASS UserInformationClass, IN PSAMPR_USER_INFO_BUFFER Buffer)
 
VOID NTAPI LsaIFree_LSAPR_POLICY_INFORMATION (IN POLICY_INFORMATION_CLASS InformationClass, IN PLSAPR_POLICY_INFORMATION PolicyInformation)
 
NTSTATUS WINAPI LsaIOpenPolicyTrusted (OUT LSAPR_HANDLE *PolicyHandle)
 
NTSTATUS WINAPI LsarClose (IN OUT LSAPR_HANDLE *ObjectHandle)
 
NTSTATUS WINAPI LsarLookupPrivilegeValue (IN LSAPR_HANDLE PolicyHandle, IN PRPC_UNICODE_STRING Name, OUT PLUID Value)
 
NTSTATUS WINAPI LsarQueryInformationPolicy (IN LSAPR_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PLSAPR_POLICY_INFORMATION *PolicyInformation)
 
NTSTATUS WINAPI SystemFunction006 (LPCSTR password, LPSTR hash)
 
NTSTATUS WINAPI SystemFunction007 (PUNICODE_STRING string, LPBYTE hash)
 
NTSTATUS WINAPI SystemFunction012 (const BYTE *in, const BYTE *key, LPBYTE out)
 

Macro Definition Documentation

◆ FIXUP_POINTER

#define FIXUP_POINTER (   Pointer,
  Offset 
)    ((Pointer != NULL) ? ((PWSTR)((ULONG_PTR)Pointer + Offset)) : NULL)

Definition at line 9 of file msv1_0.h.

◆ USER_LOGON_BAD_PASSWORD

#define USER_LOGON_BAD_PASSWORD   0x08000000

Definition at line 66 of file msv1_0.h.

◆ USER_LOGON_SUCCESS

#define USER_LOGON_SUCCESS   0x10000000

Definition at line 67 of file msv1_0.h.

Typedef Documentation

◆ ENCRYPTED_LM_OWF_PASSWORD

◆ ENCRYPTED_NT_OWF_PASSWORD

◆ LSAPR_HANDLE

Definition at line 229 of file msv1_0.h.

◆ LSAPR_POLICY_ACCOUNT_DOM_INFO

◆ LSAPR_POLICY_AUDIT_EVENTS_INFO

◆ LSAPR_POLICY_DNS_DOMAIN_INFO

◆ LSAPR_POLICY_INFORMATION

◆ LSAPR_POLICY_PD_ACCOUNT_INFO

◆ LSAPR_POLICY_PRIMARY_DOM_INFO

◆ OLD_LARGE_INTEGER

◆ PENCRYPTED_LM_OWF_PASSWORD

◆ PENCRYPTED_NT_OWF_PASSWORD

◆ PLSAPR_POLICY_ACCOUNT_DOM_INFO

◆ PLSAPR_POLICY_AUDIT_EVENTS_INFO

◆ PLSAPR_POLICY_DNS_DOMAIN_INFO

◆ PLSAPR_POLICY_INFORMATION

◆ PLSAPR_POLICY_PD_ACCOUNT_INFO

◆ PLSAPR_POLICY_PRIMARY_DOM_INFO

◆ POLD_LARGE_INTEGER

◆ POLICY_LSA_REPLICA_SRCE_INFO

◆ PPOLICY_LSA_REPLICA_SRCE_INFO

◆ PRPC_SHORT_BLOB

◆ PRPC_SID

◆ PRPC_UNICODE_STRING

◆ PSAMPR_LOGON_HOURS

◆ PSAMPR_SERVER_NAME

Definition at line 27 of file msv1_0.h.

◆ PSAMPR_SR_SECURITY_DESCRIPTOR

◆ PSAMPR_ULONG_ARRAY

◆ PSAMPR_USER_ALL_INFORMATION

◆ PSAMPR_USER_INFO_BUFFER

◆ PSAMPR_USER_INTERNAL2_INFORMATION

◆ RPC_SHORT_BLOB

◆ RPC_SID

◆ RPC_UNICODE_STRING

◆ SAMPR_HANDLE

typedef void* SAMPR_HANDLE

Definition at line 28 of file msv1_0.h.

◆ SAMPR_LOGON_HOURS

◆ SAMPR_SR_SECURITY_DESCRIPTOR

◆ SAMPR_ULONG_ARRAY

◆ SAMPR_USER_ALL_INFORMATION

◆ SAMPR_USER_INFO_BUFFER

◆ SAMPR_USER_INTERNAL2_INFORMATION

Function Documentation

◆ LsaIFree_LSAPR_POLICY_INFORMATION()

VOID NTAPI LsaIFree_LSAPR_POLICY_INFORMATION ( IN POLICY_INFORMATION_CLASS  InformationClass,
IN PLSAPR_POLICY_INFORMATION  PolicyInformation 
)

Definition at line 51 of file lsasrv.c.

53 {
54  if (PolicyInformation != NULL)
55  {
56  switch (InformationClass)
57  {
58  case PolicyAuditLogInformation: /* 1 */
59  break;
60 
61  case PolicyAuditEventsInformation: /* 2 */
62  if (PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions != NULL)
63  midl_user_free(PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions);
64  break;
65 
66  case PolicyPrimaryDomainInformation: /* 3 */
67  if (PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer != NULL)
68  midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer);
69 
70  if (PolicyInformation->PolicyPrimaryDomInfo.Sid != NULL)
71  midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Sid);
72  break;
73 
74  case PolicyPdAccountInformation: /* 4 */
75  if (PolicyInformation->PolicyPdAccountInfo.Name.Buffer != NULL)
76  midl_user_free(PolicyInformation->PolicyPdAccountInfo.Name.Buffer);
77  break;
78 
79  case PolicyAccountDomainInformation: /* 5 */
80  if (PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer != NULL)
81  midl_user_free(PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer);
82 
83  if (PolicyInformation->PolicyAccountDomainInfo.Sid != NULL)
84  midl_user_free(PolicyInformation->PolicyAccountDomainInfo.Sid);
85  break;
86 
87  case PolicyLsaServerRoleInformation: /* 6 */
88  break;
89 
90  case PolicyReplicaSourceInformation: /* 7 */
91  if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer != NULL)
92  midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer);
93 
94  if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer != NULL)
95  midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer);
96  break;
97 
98  case PolicyDefaultQuotaInformation: /* 8 */
99  break;
100 
101  case PolicyModificationInformation: /* 9 */
102  break;
103 
104  case PolicyAuditFullSetInformation: /* 10 (0xA) */
105  break;
106 
107  case PolicyAuditFullQueryInformation: /* 11 (0xB) */
108  break;
109 
110  case PolicyDnsDomainInformation: /* 12 (0xC) */
111  if (PolicyInformation->PolicyDnsDomainInfo.Name.Buffer != NULL)
112  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Name.Buffer);
113 
114  if (PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer != NULL)
115  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer);
116 
117  if (PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer != NULL)
118  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer);
119 
120  if (PolicyInformation->PolicyDnsDomainInfo.Sid != NULL)
121  midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Sid);
122  break;
123 
124  case PolicyDnsDomainInformationInt: /* 13 (0xD) */
125  if (PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer != NULL)
126  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer);
127 
128  if (PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer != NULL)
129  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer);
130 
131  if (PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer != NULL)
132  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer);
133 
134  if (PolicyInformation->PolicyDnsDomainInfoInt.Sid != NULL)
135  midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Sid);
136  break;
137 
138  case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
139  if (PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer != NULL)
140  midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer);
141 
142  if (PolicyInformation->PolicyLocalAccountDomainInfo.Sid != NULL)
143  midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.Sid);
144  break;
145 
146  default:
147  ERR("Invalid InformationClass: %lu\n", InformationClass);
148  break;
149  }
150 
151  midl_user_free(PolicyInformation);
152  }
153 }
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
Definition: lsasrv.c:346
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1714

◆ LsaIOpenPolicyTrusted()

NTSTATUS WINAPI LsaIOpenPolicyTrusted ( OUT LSAPR_HANDLE PolicyHandle)

Definition at line 15 of file policy.c.

16 {
17  PLSA_DB_OBJECT PolicyObject;
19 
20  TRACE("(%p)\n", PolicyHandle);
21 
23  NULL,
24  L"Policy",
27  TRUE,
28  &PolicyObject);
29 
30  if (NT_SUCCESS(Status))
31  *PolicyHandle = (LSAPR_HANDLE)PolicyObject;
32 
33  return Status;
34 }
NTSTATUS LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject, IN LPWSTR ContainerName, IN LPWSTR ObjectName, IN LSA_DB_OBJECT_TYPE ObjectType, IN ACCESS_MASK DesiredAccess, IN BOOLEAN Trusted, OUT PLSA_DB_OBJECT *DbObject)
Definition: database.c:710
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
PVOID LSAPR_HANDLE
Definition: msv1_0.h:229
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
#define POLICY_ALL_ACCESS
Definition: ntsecapi.h:77

Referenced by GetAccountDomainSid().

◆ LsarClose()

NTSTATUS WINAPI LsarClose ( IN OUT LSAPR_HANDLE ObjectHandle)

◆ LsarLookupPrivilegeValue()

NTSTATUS WINAPI LsarLookupPrivilegeValue ( IN LSAPR_HANDLE  PolicyHandle,
IN PRPC_UNICODE_STRING  Name,
OUT PLUID  Value 
)

◆ LsarQueryInformationPolicy()

NTSTATUS WINAPI LsarQueryInformationPolicy ( IN LSAPR_HANDLE  PolicyHandle,
IN POLICY_INFORMATION_CLASS  InformationClass,
OUT PLSAPR_POLICY_INFORMATION PolicyInformation 
)

◆ SamIConnect()

NTSTATUS NTAPI SamIConnect ( IN PSAMPR_SERVER_NAME  ServerName,
OUT SAMPR_HANDLE ServerHandle,
IN ACCESS_MASK  DesiredAccess,
IN BOOLEAN  Trusted 
)

Definition at line 64 of file samsrv.c.

68 {
69  PSAM_DB_OBJECT ServerObject;
71 
72  TRACE("SamIConnect(%p %p %lx %ld)\n",
73  ServerName, ServerHandle, DesiredAccess, Trusted);
74 
75  /* Map generic access rights */
78 
79  /* Open the Server Object */
81  NULL,
82  L"SAM",
83  0,
86  &ServerObject);
87  if (NT_SUCCESS(Status))
88  {
89  ServerObject->Trusted = Trusted;
90  *ServerHandle = (SAMPR_HANDLE)ServerObject;
91  }
92 
93  TRACE("SamIConnect done (Status 0x%08lx)\n", Status);
94 
95  return Status;
96 }
PGENERIC_MAPPING pServerMapping
Definition: samrpc.c:56
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN Trusted
Definition: samsrv.h:54
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlMapGenericMask(PACCESS_MASK AccessMask, PGENERIC_MAPPING GenericMapping)
NTSTATUS SampOpenDbObject(IN PSAM_DB_OBJECT ParentObject, IN LPWSTR ContainerName, IN LPWSTR ObjectName, IN ULONG RelativeId, IN SAM_DB_OBJECT_TYPE ObjectType, IN ACCESS_MASK DesiredAccess, OUT PSAM_DB_OBJECT *DbObject)
Definition: database.c:171
void * SAMPR_HANDLE
Definition: authpackage.c:113

◆ SamIFree_SAMPR_ULONG_ARRAY()

VOID NTAPI SamIFree_SAMPR_ULONG_ARRAY ( PSAMPR_ULONG_ARRAY  Ptr)

Definition at line 515 of file samsrv.c.

516 {
517  if (Ptr == NULL)
518  return;
519 
520  if (Ptr->Element != NULL)
521  {
522  MIDL_user_free(Ptr->Element);
523  Ptr->Element = NULL;
524  Ptr->Count = 0;
525  }
526 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define NULL
Definition: types.h:112
void __RPC_USER MIDL_user_free(void *p)
Definition: irotp.c:376

◆ SamIFree_SAMPR_USER_INFO_BUFFER()

VOID NTAPI SamIFree_SAMPR_USER_INFO_BUFFER ( PSAMPR_USER_INFO_BUFFER  Ptr,
USER_INFORMATION_CLASS  InformationClass 
)

Definition at line 531 of file samsrv.c.

533 {
534  if (Ptr == NULL)
535  return;
536 
537  switch (InformationClass)
538  {
540  if (Ptr->General.UserName.Buffer != NULL)
541  MIDL_user_free(Ptr->General.UserName.Buffer);
542 
543  if (Ptr->General.FullName.Buffer != NULL)
544  MIDL_user_free(Ptr->General.FullName.Buffer);
545 
546  if (Ptr->General.AdminComment.Buffer != NULL)
547  MIDL_user_free(Ptr->General.AdminComment.Buffer);
548 
549  if (Ptr->General.UserComment.Buffer != NULL)
550  MIDL_user_free(Ptr->General.UserComment.Buffer);
551  break;
552 
554  if (Ptr->Preferences.UserComment.Buffer != NULL)
555  MIDL_user_free(Ptr->Preferences.UserComment.Buffer);
556 
557  if (Ptr->Preferences.Reserved1.Buffer != NULL)
558  MIDL_user_free(Ptr->Preferences.Reserved1.Buffer);
559  break;
560 
562  if (Ptr->Logon.UserName.Buffer != NULL)
563  MIDL_user_free(Ptr->Logon.UserName.Buffer);
564 
565  if (Ptr->Logon.FullName.Buffer != NULL)
566  MIDL_user_free(Ptr->Logon.FullName.Buffer);
567 
568  if (Ptr->Logon.HomeDirectory.Buffer != NULL)
569  MIDL_user_free(Ptr->Logon.HomeDirectory.Buffer);
570 
571  if (Ptr->Logon.HomeDirectoryDrive.Buffer != NULL)
572  MIDL_user_free(Ptr->Logon.HomeDirectoryDrive.Buffer);
573 
574  if (Ptr->Logon.ScriptPath.Buffer != NULL)
575  MIDL_user_free(Ptr->Logon.ScriptPath.Buffer);
576 
577  if (Ptr->Logon.ProfilePath.Buffer != NULL)
578  MIDL_user_free(Ptr->Logon.ProfilePath.Buffer);
579 
580  if (Ptr->Logon.WorkStations.Buffer != NULL)
581  MIDL_user_free(Ptr->Logon.WorkStations.Buffer);
582 
583  if (Ptr->Logon.LogonHours.LogonHours != NULL)
584  MIDL_user_free(Ptr->Logon.LogonHours.LogonHours);
585  break;
586 
588  if (Ptr->LogonHours.LogonHours.LogonHours != NULL)
589  MIDL_user_free(Ptr->LogonHours.LogonHours.LogonHours);
590  break;
591 
593  if (Ptr->Account.UserName.Buffer != NULL)
594  MIDL_user_free(Ptr->Account.UserName.Buffer);
595 
596  if (Ptr->Account.FullName.Buffer != NULL)
597  MIDL_user_free(Ptr->Account.FullName.Buffer);
598 
599  if (Ptr->Account.HomeDirectory.Buffer != NULL)
600  MIDL_user_free(Ptr->Account.HomeDirectory.Buffer);
601 
602  if (Ptr->Account.HomeDirectoryDrive.Buffer != NULL)
603  MIDL_user_free(Ptr->Account.HomeDirectoryDrive.Buffer);
604 
605  if (Ptr->Account.ScriptPath.Buffer != NULL)
606  MIDL_user_free(Ptr->Account.ScriptPath.Buffer);
607 
608  if (Ptr->Account.ProfilePath.Buffer != NULL)
609  MIDL_user_free(Ptr->Account.ProfilePath.Buffer);
610 
611  if (Ptr->Account.AdminComment.Buffer != NULL)
612  MIDL_user_free(Ptr->Account.AdminComment.Buffer);
613 
614  if (Ptr->Account.WorkStations.Buffer != NULL)
615  MIDL_user_free(Ptr->Account.WorkStations.Buffer);
616 
617  if (Ptr->Account.LogonHours.LogonHours != NULL)
618  MIDL_user_free(Ptr->Account.LogonHours.LogonHours);
619  break;
620 
621  case UserNameInformation:
622  if (Ptr->Name.UserName.Buffer != NULL)
623  MIDL_user_free(Ptr->Name.UserName.Buffer);
624 
625  if (Ptr->Name.FullName.Buffer != NULL)
626  MIDL_user_free(Ptr->Name.FullName.Buffer);
627  break;
628 
630  if (Ptr->AccountName.UserName.Buffer != NULL)
631  MIDL_user_free(Ptr->AccountName.UserName.Buffer);
632  break;
633 
635  if (Ptr->FullName.FullName.Buffer != NULL)
636  MIDL_user_free(Ptr->FullName.FullName.Buffer);
637  break;
638 
640  break;
641 
642  case UserHomeInformation:
643  if (Ptr->Home.HomeDirectory.Buffer != NULL)
644  MIDL_user_free(Ptr->Home.HomeDirectory.Buffer);
645 
646  if (Ptr->Home.HomeDirectoryDrive.Buffer != NULL)
647  MIDL_user_free(Ptr->Home.HomeDirectoryDrive.Buffer);
648  break;
649 
651  if (Ptr->Script.ScriptPath.Buffer != NULL)
652  MIDL_user_free(Ptr->Script.ScriptPath.Buffer);
653  break;
654 
656  if (Ptr->Profile.ProfilePath.Buffer != NULL)
657  MIDL_user_free(Ptr->Profile.ProfilePath.Buffer);
658  break;
659 
661  if (Ptr->AdminComment.AdminComment.Buffer != NULL)
662  MIDL_user_free(Ptr->AdminComment.AdminComment.Buffer);
663  break;
664 
666  if (Ptr->WorkStations.WorkStations.Buffer != NULL)
667  MIDL_user_free(Ptr->WorkStations.WorkStations.Buffer);
668  break;
669 
671  ERR("Information class UserSetPasswordInformation cannot be queried!\n");
672  break;
673 
675  break;
676 
678  break;
679 
681  break;
682 
684  break;
685 
687  if (Ptr->Parameters.Parameters.Buffer != NULL)
688  MIDL_user_free(Ptr->Parameters.Parameters.Buffer);
689  break;
690 
691  case UserAllInformation:
692  if (Ptr->All.UserName.Buffer != NULL)
693  MIDL_user_free(Ptr->All.UserName.Buffer);
694 
695  if (Ptr->All.FullName.Buffer != NULL)
696  MIDL_user_free(Ptr->All.FullName.Buffer);
697 
698  if (Ptr->All.HomeDirectory.Buffer != NULL)
699  MIDL_user_free(Ptr->All.HomeDirectory.Buffer);
700 
701  if (Ptr->All.HomeDirectoryDrive.Buffer != NULL)
702  MIDL_user_free(Ptr->All.HomeDirectoryDrive.Buffer);
703 
704  if (Ptr->All.ScriptPath.Buffer != NULL)
705  MIDL_user_free(Ptr->All.ScriptPath.Buffer);
706 
707  if (Ptr->All.ProfilePath.Buffer != NULL)
708  MIDL_user_free(Ptr->All.ProfilePath.Buffer);
709 
710  if (Ptr->All.AdminComment.Buffer != NULL)
711  MIDL_user_free(Ptr->All.AdminComment.Buffer);
712 
713  if (Ptr->All.WorkStations.Buffer != NULL)
714  MIDL_user_free(Ptr->All.WorkStations.Buffer);
715 
716  if (Ptr->All.UserComment.Buffer != NULL)
717  MIDL_user_free(Ptr->All.UserComment.Buffer);
718 
719  if (Ptr->All.Parameters.Buffer != NULL)
720  MIDL_user_free(Ptr->All.Parameters.Buffer);
721 
722  if (Ptr->All.LmOwfPassword.Buffer != NULL)
723  MIDL_user_free(Ptr->All.LmOwfPassword.Buffer);
724 
725  if (Ptr->All.NtOwfPassword.Buffer != NULL)
726  MIDL_user_free(Ptr->All.NtOwfPassword.Buffer);
727 
728  if (Ptr->All.PrivateData.Buffer != NULL)
729  MIDL_user_free(Ptr->All.PrivateData.Buffer);
730 
731  if (Ptr->All.SecurityDescriptor.SecurityDescriptor != NULL)
732  MIDL_user_free(Ptr->All.SecurityDescriptor.SecurityDescriptor);
733 
734  if (Ptr->All.LogonHours.LogonHours != NULL)
735  MIDL_user_free(Ptr->All.LogonHours.LogonHours);
736  break;
737 
738  default:
739  FIXME("Unsupported information class: %lu\n", InformationClass);
740  break;
741  }
742 
744 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1714
void __RPC_USER MIDL_user_free(void *p)
Definition: irotp.c:376

Referenced by LsaApLogonUserEx2().

◆ SamIFreeVoid()

VOID NTAPI SamIFreeVoid ( PVOID  Ptr)

Definition at line 146 of file samsrv.c.

147 {
149 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
void __RPC_USER MIDL_user_free(void *p)
Definition: irotp.c:376

Referenced by MsvpChangePassword().

◆ SamrChangePasswordUser()

NTSTATUS NTAPI SamrChangePasswordUser ( IN SAMPR_HANDLE  UserHandle,
IN unsigned char  LmPresent,
IN PENCRYPTED_LM_OWF_PASSWORD  OldLmEncryptedWithNewLm,
IN PENCRYPTED_LM_OWF_PASSWORD  NewLmEncryptedWithOldLm,
IN unsigned char  NtPresent,
IN PENCRYPTED_NT_OWF_PASSWORD  OldNtEncryptedWithNewNt,
IN PENCRYPTED_NT_OWF_PASSWORD  NewNtEncryptedWithOldNt,
IN unsigned char  NtCrossEncryptionPresent,
IN PENCRYPTED_NT_OWF_PASSWORD  NewNtEncryptedWithNewLm,
IN unsigned char  LmCrossEncryptionPresent,
IN PENCRYPTED_LM_OWF_PASSWORD  NewLmEncryptedWithNewNt 
)

Definition at line 8334 of file samrpc.c.

8345 {
8346  ENCRYPTED_LM_OWF_PASSWORD StoredLmPassword;
8347  ENCRYPTED_NT_OWF_PASSWORD StoredNtPassword;
8348  LM_OWF_PASSWORD OldLmPassword;
8349  LM_OWF_PASSWORD NewLmPassword;
8350  NT_OWF_PASSWORD OldNtPassword;
8351  NT_OWF_PASSWORD NewNtPassword;
8352  BOOLEAN StoredLmPresent = FALSE;
8353  BOOLEAN StoredNtPresent = FALSE;
8354  BOOLEAN StoredLmEmpty = TRUE;
8355  BOOLEAN StoredNtEmpty = TRUE;
8356  PSAM_DB_OBJECT UserObject;
8357  ULONG Length;
8358  SAM_USER_FIXED_DATA UserFixedData;
8359  SAM_DOMAIN_FIXED_DATA DomainFixedData;
8360  LARGE_INTEGER SystemTime;
8361  NTSTATUS Status;
8362 
8363  DBG_UNREFERENCED_LOCAL_VARIABLE(StoredLmPresent);
8364  DBG_UNREFERENCED_LOCAL_VARIABLE(StoredNtPresent);
8365  DBG_UNREFERENCED_LOCAL_VARIABLE(StoredLmEmpty);
8366 
8367  TRACE("SamrChangePasswordUser(%p %u %p %p %u %p %p %u %p %u %p)\n",
8368  UserHandle, LmPresent, OldLmEncryptedWithNewLm, NewLmEncryptedWithOldLm,
8369  NtPresent, OldNtEncryptedWithNewNt, NewNtEncryptedWithOldNt, NtCrossEncryptionPresent,
8370  NewNtEncryptedWithNewLm, LmCrossEncryptionPresent, NewLmEncryptedWithNewNt);
8371 
8373  TRUE);
8374 
8375  /* Validate the user handle */
8376  Status = SampValidateDbObject(UserHandle,
8379  &UserObject);
8380  if (!NT_SUCCESS(Status))
8381  {
8382  TRACE("SampValidateDbObject failed with status 0x%08lx\n", Status);
8383  goto done;
8384  }
8385 
8386  /* Get the current time */
8387  Status = NtQuerySystemTime(&SystemTime);
8388  if (!NT_SUCCESS(Status))
8389  {
8390  TRACE("NtQuerySystemTime failed (Status 0x%08lx)\n", Status);
8391  goto done;
8392  }
8393 
8394  /* Retrieve the LM password */
8396  Status = SampGetObjectAttribute(UserObject,
8397  L"LMPwd",
8398  NULL,
8399  &StoredLmPassword,
8400  &Length);
8401  if (NT_SUCCESS(Status))
8402  {
8403  if (Length == sizeof(ENCRYPTED_LM_OWF_PASSWORD))
8404  {
8405  StoredLmPresent = TRUE;
8406  if (!RtlEqualMemory(&StoredLmPassword,
8407  &EmptyLmHash,
8408  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8409  StoredLmEmpty = FALSE;
8410  }
8411  }
8412 
8413  /* Retrieve the NT password */
8415  Status = SampGetObjectAttribute(UserObject,
8416  L"NTPwd",
8417  NULL,
8418  &StoredNtPassword,
8419  &Length);
8420  if (NT_SUCCESS(Status))
8421  {
8422  if (Length == sizeof(ENCRYPTED_NT_OWF_PASSWORD))
8423  {
8424  StoredNtPresent = TRUE;
8425  if (!RtlEqualMemory(&StoredNtPassword,
8426  &EmptyNtHash,
8427  sizeof(ENCRYPTED_NT_OWF_PASSWORD)))
8428  StoredNtEmpty = FALSE;
8429  }
8430  }
8431 
8432  /* Retrieve the fixed size user data */
8433  Length = sizeof(SAM_USER_FIXED_DATA);
8434  Status = SampGetObjectAttribute(UserObject,
8435  L"F",
8436  NULL,
8437  &UserFixedData,
8438  &Length);
8439  if (!NT_SUCCESS(Status))
8440  {
8441  TRACE("SampGetObjectAttribute failed to retrieve the fixed user data (Status 0x%08lx)\n", Status);
8442  goto done;
8443  }
8444 
8445  /* Check if we can change the password at this time */
8446  if ((StoredLmEmpty == FALSE) || (StoredNtEmpty == FALSE))
8447  {
8448  /* Get fixed domain data */
8449  Length = sizeof(SAM_DOMAIN_FIXED_DATA);
8451  L"F",
8452  NULL,
8453  &DomainFixedData,
8454  &Length);
8455  if (!NT_SUCCESS(Status))
8456  {
8457  TRACE("SampGetObjectAttribute failed to retrieve the fixed domain data (Status 0x%08lx)\n", Status);
8458  goto done;
8459  }
8460 
8461  if (DomainFixedData.MinPasswordAge.QuadPart > 0)
8462  {
8463  if (SystemTime.QuadPart < (UserFixedData.PasswordLastSet.QuadPart + DomainFixedData.MinPasswordAge.QuadPart))
8464  {
8466  goto done;
8467  }
8468  }
8469  }
8470 
8471  /* Decrypt the LM passwords, if present */
8472  if (LmPresent)
8473  {
8474  Status = SystemFunction013((const BYTE *)NewLmEncryptedWithOldLm,
8475  (const BYTE *)&StoredLmPassword,
8476  (LPBYTE)&NewLmPassword);
8477  if (!NT_SUCCESS(Status))
8478  {
8479  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8480  goto done;
8481  }
8482 
8483  Status = SystemFunction013((const BYTE *)OldLmEncryptedWithNewLm,
8484  (const BYTE *)&NewLmPassword,
8485  (LPBYTE)&OldLmPassword);
8486  if (!NT_SUCCESS(Status))
8487  {
8488  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8489  goto done;
8490  }
8491  }
8492 
8493  /* Decrypt the NT passwords, if present */
8494  if (NtPresent)
8495  {
8496  Status = SystemFunction013((const BYTE *)NewNtEncryptedWithOldNt,
8497  (const BYTE *)&StoredNtPassword,
8498  (LPBYTE)&NewNtPassword);
8499  if (!NT_SUCCESS(Status))
8500  {
8501  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8502  goto done;
8503  }
8504 
8505  Status = SystemFunction013((const BYTE *)OldNtEncryptedWithNewNt,
8506  (const BYTE *)&NewNtPassword,
8507  (LPBYTE)&OldNtPassword);
8508  if (!NT_SUCCESS(Status))
8509  {
8510  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8511  goto done;
8512  }
8513  }
8514 
8515  /* Check if the old passwords match the stored ones */
8516  if (NtPresent)
8517  {
8518  if (LmPresent)
8519  {
8520  if (!RtlEqualMemory(&StoredLmPassword,
8521  &OldLmPassword,
8522  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8523  {
8524  TRACE("Old LM Password does not match!\n");
8526  }
8527  else
8528  {
8529  if (!RtlEqualMemory(&StoredNtPassword,
8530  &OldNtPassword,
8531  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8532  {
8533  TRACE("Old NT Password does not match!\n");
8535  }
8536  }
8537  }
8538  else
8539  {
8540  if (!RtlEqualMemory(&StoredNtPassword,
8541  &OldNtPassword,
8542  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8543  {
8544  TRACE("Old NT Password does not match!\n");
8546  }
8547  }
8548  }
8549  else
8550  {
8551  if (LmPresent)
8552  {
8553  if (!RtlEqualMemory(&StoredLmPassword,
8554  &OldLmPassword,
8555  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8556  {
8557  TRACE("Old LM Password does not match!\n");
8559  }
8560  }
8561  else
8562  {
8564  }
8565  }
8566 
8567  /* Store the new password hashes */
8568  if (NT_SUCCESS(Status))
8569  {
8570  Status = SampSetUserPassword(UserObject,
8571  &NewNtPassword,
8572  NtPresent,
8573  &NewLmPassword,
8574  LmPresent);
8575  if (NT_SUCCESS(Status))
8576  {
8577  /* Update PasswordLastSet */
8578  UserFixedData.PasswordLastSet.QuadPart = SystemTime.QuadPart;
8579 
8580  /* Set the fixed size user data */
8581  Length = sizeof(SAM_USER_FIXED_DATA);
8582  Status = SampSetObjectAttribute(UserObject,
8583  L"F",
8584  REG_BINARY,
8585  &UserFixedData,
8586  Length);
8587  }
8588  }
8589 
8591  {
8592  /* Update BadPasswordCount and LastBadPasswordTime */
8593  UserFixedData.BadPasswordCount++;
8594  UserFixedData.LastBadPasswordTime.QuadPart = SystemTime.QuadPart;
8595 
8596  /* Set the fixed size user data */
8597  Length = sizeof(SAM_USER_FIXED_DATA);
8598  Status = SampSetObjectAttribute(UserObject,
8599  L"F",
8600  REG_BINARY,
8601  &UserFixedData,
8602  Length);
8603  }
8604 
8605 done:
8607 
8608  return Status;
8609 }
#define STATUS_WRONG_PASSWORD
Definition: ntstatus.h:342
struct _SAM_USER_FIXED_DATA SAM_USER_FIXED_DATA
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct _SAM_DOMAIN_FIXED_DATA SAM_DOMAIN_FIXED_DATA
#define REG_BINARY
Definition: nt_native.h:1496
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LARGE_INTEGER LastBadPasswordTime
Definition: samsrv.h:105
NTSTATUS SampSetObjectAttribute(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, ULONG AttributeType, LPVOID AttributeData, ULONG AttributeSize)
Definition: database.c:499
LONG NTSTATUS
Definition: precomp.h:26
LARGE_INTEGER MinPasswordAge
Definition: samsrv.h:74
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
ENCRYPTED_NT_OWF_PASSWORD EmptyNtHash
Definition: samsrv.c:26
RTL_RESOURCE SampResource
Definition: samsrv.c:28
#define STATUS_ACCOUNT_RESTRICTION
Definition: ntstatus.h:346
struct _ENCRYPTED_LM_OWF_PASSWORD ENCRYPTED_LM_OWF_PASSWORD
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
NTSTATUS SampSetUserPassword(IN PSAM_DB_OBJECT UserObject, IN PENCRYPTED_NT_OWF_PASSWORD NtPassword, IN BOOLEAN NtPasswordPresent, IN PENCRYPTED_LM_OWF_PASSWORD LmPassword, IN BOOLEAN LmPasswordPresent)
Definition: user.c:399
Status
Definition: gdiplustypes.h:24
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:320
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
NTSTATUS WINAPI SystemFunction013(const BYTE *in, const BYTE *key, LPBYTE out)
Definition: sysfunc.c:383
LARGE_INTEGER PasswordLastSet
Definition: samsrv.h:103
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
NTSTATUS SampGetObjectAttribute(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, PULONG AttributeType, LPVOID AttributeData, PULONG AttributeSize)
Definition: database.c:514
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: xxhash.c:193
ENCRYPTED_LM_OWF_PASSWORD EmptyLmHash
Definition: samsrv.c:27
USHORT BadPasswordCount
Definition: samsrv.h:111
struct _SAM_DB_OBJECT * ParentObject
Definition: samsrv.h:55
#define NULL
Definition: types.h:112
struct _ENCRYPTED_LM_OWF_PASSWORD ENCRYPTED_NT_OWF_PASSWORD
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
Definition: time.c:417
LONGLONG QuadPart
Definition: typedefs.h:114
#define USER_CHANGE_PASSWORD
Definition: ntsam.h:132
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)

Referenced by MsvpChangePassword(), and SamChangePasswordUser().

◆ SamrCloseHandle()

NTSTATUS NTAPI SamrCloseHandle ( IN OUT SAMPR_HANDLE SamHandle)

Definition at line 160 of file samrpc.c.

161 {
162  PSAM_DB_OBJECT DbObject;
164 
165  TRACE("SamrCloseHandle(%p)\n", SamHandle);
166 
168  TRUE);
169 
170  Status = SampValidateDbObject(*SamHandle,
172  0,
173  &DbObject);
174  if (Status == STATUS_SUCCESS)
175  {
176  Status = SampCloseDbObject(DbObject);
177  *SamHandle = NULL;
178  }
179 
181 
182  TRACE("SamrCloseHandle done (Status 0x%08lx)\n", Status);
183 
184  return Status;
185 }
#define TRUE
Definition: types.h:120
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
RTL_RESOURCE SampResource
Definition: samsrv.c:28
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
NTSTATUS SampCloseDbObject(PSAM_DB_OBJECT DbObject)
Definition: database.c:344
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by SamrGetDomainPasswordInformation().

◆ SamrLookupDomainInSamServer()

NTSTATUS NTAPI SamrLookupDomainInSamServer ( IN SAMPR_HANDLE  ServerHandle,
IN PRPC_UNICODE_STRING  Name,
OUT PRPC_SID DomainId 
)

Definition at line 497 of file samrpc.c.

500 {
501  PSAM_DB_OBJECT ServerObject;
502  HANDLE DomainsKeyHandle = NULL;
503  HANDLE DomainKeyHandle = NULL;
504  WCHAR DomainKeyName[64];
505  ULONG Index;
506  WCHAR DomainNameString[MAX_COMPUTERNAME_LENGTH + 1];
507  UNICODE_STRING DomainName;
508  ULONG Length;
509  BOOL Found = FALSE;
511 
512  TRACE("SamrLookupDomainInSamServer(%p %p %p)\n",
513  ServerHandle, Name, DomainId);
514 
516  TRUE);
517 
518  /* Validate the server handle */
519  Status = SampValidateDbObject(ServerHandle,
522  &ServerObject);
523  if (!NT_SUCCESS(Status))
524  goto done;
525 
526  *DomainId = NULL;
527 
528  Status = SampRegOpenKey(ServerObject->KeyHandle,
529  L"Domains",
530  KEY_READ,
531  &DomainsKeyHandle);
532  if (!NT_SUCCESS(Status))
533  goto done;
534 
535  Index = 0;
536  while (Found == FALSE)
537  {
538  Status = SampRegEnumerateSubKey(DomainsKeyHandle,
539  Index,
540  64,
541  DomainKeyName);
542  if (!NT_SUCCESS(Status))
543  {
546  break;
547  }
548 
549  TRACE("Domain key name: %S\n", DomainKeyName);
550 
551  Status = SampRegOpenKey(DomainsKeyHandle,
552  DomainKeyName,
553  KEY_READ,
554  &DomainKeyHandle);
555  if (NT_SUCCESS(Status))
556  {
557  Length = (MAX_COMPUTERNAME_LENGTH + 1) * sizeof(WCHAR);
558  Status = SampRegQueryValue(DomainKeyHandle,
559  L"Name",
560  NULL,
561  (PVOID)&DomainNameString,
562  &Length);
563  if (NT_SUCCESS(Status))
564  {
565  TRACE("Domain name: %S\n", DomainNameString);
566 
567  RtlInitUnicodeString(&DomainName,
568  DomainNameString);
569  if (RtlEqualUnicodeString(&DomainName, (PUNICODE_STRING)Name, TRUE))
570  {
571  TRACE("Found it!\n");
572  Found = TRUE;
573 
574  Status = SampRegQueryValue(DomainKeyHandle,
575  L"SID",
576  NULL,
577  NULL,
578  &Length);
579  if (NT_SUCCESS(Status))
580  {
581  *DomainId = midl_user_allocate(Length);
582 
583  SampRegQueryValue(DomainKeyHandle,
584  L"SID",
585  NULL,
586  (PVOID)*DomainId,
587  &Length);
588 
590  break;
591  }
592  }
593  }
594 
595  SampRegCloseKey(&DomainKeyHandle);
596  }
597 
598  Index++;
599  }
600 
601 done:
602  SampRegCloseKey(&DomainKeyHandle);
603  SampRegCloseKey(&DomainsKeyHandle);
604 
606 
607  return Status;
608 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NO_SUCH_DOMAIN
Definition: ntstatus.h:459
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
RTL_RESOURCE SampResource
Definition: samsrv.c:28
NTSTATUS SampRegCloseKey(IN OUT PHANDLE KeyHandle)
Definition: registry.c:26
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SAM_SERVER_LOOKUP_DOMAIN
Definition: ntsam.h:104
return Found
Definition: dirsup.c:1270
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ WDFCOLLECTION _In_ ULONG Index
NTSTATUS SampRegEnumerateSubKey(IN HANDLE KeyHandle, IN ULONG Index, IN ULONG Length, OUT LPWSTR Buffer)
Definition: registry.c:101
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
NTSTATUS SampRegQueryValue(IN HANDLE KeyHandle, IN LPCWSTR ValueName, OUT PULONG Type OPTIONAL, OUT PVOID Data OPTIONAL, IN OUT PULONG DataLength OPTIONAL)
Definition: registry.c:332
static const WCHAR L[]
Definition: oid.c:1250
HANDLE KeyHandle
Definition: samsrv.h:51
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
NTSTATUS SampRegOpenKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle)
Definition: registry.c:158
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T len)
Definition: samrpc.c:114

Referenced by MsvpChangePassword(), and SamLookupDomainInSamServer().

◆ SamrLookupNamesInDomain()

NTSTATUS NTAPI SamrLookupNamesInDomain ( IN SAMPR_HANDLE  DomainHandle,
IN ULONG  Count,
IN RPC_UNICODE_STRING  Names[],
OUT PSAMPR_ULONG_ARRAY  RelativeIds,
OUT PSAMPR_ULONG_ARRAY  Use 
)

Definition at line 3567 of file samrpc.c.

3572 {
3573  PSAM_DB_OBJECT DomainObject;
3574  HANDLE AccountsKeyHandle = NULL;
3575  HANDLE NamesKeyHandle = NULL;
3576  ULONG MappedCount = 0;
3577  ULONG DataLength;
3578  ULONG i;
3579  ULONG RelativeId;
3580  NTSTATUS Status;
3581 
3582  TRACE("SamrLookupNamesInDomain(%p %lu %p %p %p)\n",
3583  DomainHandle, Count, Names, RelativeIds, Use);
3584 
3586  TRUE);
3587 
3588  /* Validate the domain handle */
3589  Status = SampValidateDbObject(DomainHandle,
3591  DOMAIN_LOOKUP,
3592  &DomainObject);
3593  if (!NT_SUCCESS(Status))
3594  {
3595  TRACE("failed with status 0x%08lx\n", Status);
3596  goto done;
3597  }
3598 
3599  RelativeIds->Count = 0;
3600  Use->Count = 0;
3601 
3602  if (Count == 0)
3603  {
3605  goto done;
3606  }
3607 
3608  /* Allocate the relative IDs array */
3609  RelativeIds->Element = midl_user_allocate(Count * sizeof(ULONG));
3610  if (RelativeIds->Element == NULL)
3611  {
3613  goto done;
3614  }
3615 
3616  /* Allocate the use array */
3617  Use->Element = midl_user_allocate(Count * sizeof(ULONG));
3618  if (Use->Element == NULL)
3619  {
3621  goto done;
3622  }
3623 
3624  RelativeIds->Count = Count;
3625  Use->Count = Count;
3626 
3627  for (i = 0; i < Count; i++)
3628  {
3629  TRACE("Name: %S\n", Names[i].Buffer);
3630 
3631  RelativeId = 0;
3632 
3633  /* Lookup aliases */
3634  Status = SampRegOpenKey(DomainObject->KeyHandle,
3635  L"Aliases",
3636  KEY_READ,
3637  &AccountsKeyHandle);
3638  if (NT_SUCCESS(Status))
3639  {
3640  Status = SampRegOpenKey(AccountsKeyHandle,
3641  L"Names",
3642  KEY_READ,
3643  &NamesKeyHandle);
3644  if (NT_SUCCESS(Status))
3645  {
3646  DataLength = sizeof(ULONG);
3647  Status = SampRegQueryValue(NamesKeyHandle,
3648  Names[i].Buffer,
3649  NULL,
3650  &RelativeId,
3651  &DataLength);
3652 
3653  SampRegCloseKey(&NamesKeyHandle);
3654  }
3655 
3656  SampRegCloseKey(&AccountsKeyHandle);
3657  }
3658 
3660  break;
3661 
3662  /* Return alias account */
3663  if (NT_SUCCESS(Status) && RelativeId != 0)
3664  {
3665  TRACE("Rid: %lu\n", RelativeId);
3666  RelativeIds->Element[i] = RelativeId;
3667  Use->Element[i] = SidTypeAlias;
3668  MappedCount++;
3669  continue;
3670  }
3671 
3672  /* Lookup groups */
3673  Status = SampRegOpenKey(DomainObject->KeyHandle,
3674  L"Groups",
3675  KEY_READ,
3676  &AccountsKeyHandle);
3677  if (NT_SUCCESS(Status))
3678  {
3679  Status = SampRegOpenKey(AccountsKeyHandle,
3680  L"Names",
3681  KEY_READ,
3682  &NamesKeyHandle);
3683  if (NT_SUCCESS(Status))
3684  {
3685  DataLength = sizeof(ULONG);
3686  Status = SampRegQueryValue(NamesKeyHandle,
3687  Names[i].Buffer,
3688  NULL,
3689  &RelativeId,
3690  &DataLength);
3691 
3692  SampRegCloseKey(&NamesKeyHandle);
3693  }
3694 
3695  SampRegCloseKey(&AccountsKeyHandle);
3696  }
3697 
3699  break;
3700 
3701  /* Return group account */
3702  if (NT_SUCCESS(Status) && RelativeId != 0)
3703  {
3704  TRACE("Rid: %lu\n", RelativeId);
3705  RelativeIds->Element[i] = RelativeId;
3706  Use->Element[i] = SidTypeGroup;
3707  MappedCount++;
3708  continue;
3709  }
3710 
3711  /* Lookup users */
3712  Status = SampRegOpenKey(DomainObject->KeyHandle,
3713  L"Users",
3714  KEY_READ,
3715  &AccountsKeyHandle);
3716  if (NT_SUCCESS(Status))
3717  {
3718  Status = SampRegOpenKey(AccountsKeyHandle,
3719  L"Names",
3720  KEY_READ,
3721  &NamesKeyHandle);
3722  if (NT_SUCCESS(Status))
3723  {
3724  DataLength = sizeof(ULONG);
3725  Status = SampRegQueryValue(NamesKeyHandle,
3726  Names[i].Buffer,
3727  NULL,
3728  &RelativeId,
3729  &DataLength);
3730 
3731  SampRegCloseKey(&NamesKeyHandle);
3732  }
3733 
3734  SampRegCloseKey(&AccountsKeyHandle);
3735  }
3736 
3738  break;
3739 
3740  /* Return user account */
3741  if (NT_SUCCESS(Status) && RelativeId != 0)
3742  {
3743  TRACE("Rid: %lu\n", RelativeId);
3744  RelativeIds->Element[i] = RelativeId;
3745  Use->Element[i] = SidTypeUser;
3746  MappedCount++;
3747  continue;
3748  }
3749 
3750  /* Return unknown account */
3751  RelativeIds->Element[i] = 0;
3752  Use->Element[i] = SidTypeUnknown;
3753  }
3754 
3755 done:
3758 
3759  if (NT_SUCCESS(Status))
3760  {
3761  if (MappedCount == 0)
3763  else if (MappedCount < Count)
3765  }
3766  else
3767  {
3768  if (RelativeIds->Element != NULL)
3769  {
3770  midl_user_free(RelativeIds->Element);
3771  RelativeIds->Element = NULL;
3772  }
3773 
3774  RelativeIds->Count = 0;
3775 
3776  if (Use->Element != NULL)
3777  {
3778  midl_user_free(Use->Element);
3779  Use->Element = NULL;
3780  }
3781 
3782  Use->Count = 0;
3783  }
3784 
3786 
3787  TRACE("Returned Status %lx\n", Status);
3788 
3789  return Status;
3790 }
PWSTR Names[NAMES_COUNT]
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
Definition: samrpc.c:120
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
#define STATUS_NONE_MAPPED
Definition: ntstatus.h:351
RTL_RESOURCE SampResource
Definition: samsrv.c:28
NTSTATUS SampRegCloseKey(IN OUT PHANDLE KeyHandle)
Definition: registry.c:26
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1437
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
int Count
Definition: noreturn.cpp:7
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
NTSTATUS SampRegQueryValue(IN HANDLE KeyHandle, IN LPCWSTR ValueName, OUT PULONG Type OPTIONAL, OUT PVOID Data OPTIONAL, IN OUT PULONG DataLength OPTIONAL)
Definition: registry.c:332
static const WCHAR L[]
Definition: oid.c:1250
HANDLE KeyHandle
Definition: samsrv.h:51
#define STATUS_SOME_NOT_MAPPED
Definition: ntstatus.h:86
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
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
Definition: glfuncs.h:248
NTSTATUS SampRegOpenKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle)
Definition: registry.c:158
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define DOMAIN_LOOKUP
Definition: ntsam.h:42
#define STATUS_SUCCESS
Definition: shellext.h:65
void __RPC_FAR *__RPC_USER midl_user_allocate(SIZE_T len)
Definition: samrpc.c:114

◆ SamrOpenDomain()

NTSTATUS NTAPI SamrOpenDomain ( IN SAMPR_HANDLE  ServerHandle,
IN ACCESS_MASK  DesiredAccess,
IN PRPC_SID  DomainId,
OUT SAMPR_HANDLE DomainHandle 
)

Definition at line 824 of file samrpc.c.

828 {
829  PSAM_DB_OBJECT ServerObject;
830  PSAM_DB_OBJECT DomainObject;
832 
833  TRACE("SamrOpenDomain(%p %lx %p %p)\n",
834  ServerHandle, DesiredAccess, DomainId, DomainHandle);
835 
836  /* Map generic access rights */
838  &DomainMapping);
839 
841  TRUE);
842 
843  /* Validate the server handle */
844  Status = SampValidateDbObject(ServerHandle,
847  &ServerObject);
848  if (!NT_SUCCESS(Status))
849  return Status;
850 
851  /* Validate the Domain SID */
852  if ((DomainId->Revision != SID_REVISION) ||
853  (DomainId->SubAuthorityCount > SID_MAX_SUB_AUTHORITIES) ||
854  (memcmp(&DomainId->IdentifierAuthority, &NtSidAuthority, sizeof(SID_IDENTIFIER_AUTHORITY)) != 0))
856 
857  /* Open the domain object */
858  if ((DomainId->SubAuthorityCount == 1) &&
859  (DomainId->SubAuthority[0] == SECURITY_BUILTIN_DOMAIN_RID))
860  {
861  /* Builtin domain object */
862  TRACE("Opening the builtin domain object.\n");
863 
864  Status = SampOpenDbObject(ServerObject,
865  L"Domains",
866  L"Builtin",
867  0,
870  &DomainObject);
871  }
872  else if ((DomainId->SubAuthorityCount == 4) &&
873  (DomainId->SubAuthority[0] == SECURITY_NT_NON_UNIQUE))
874  {
875  /* Account domain object */
876  TRACE("Opening the account domain object.\n");
877 
878  /* FIXME: Check the account domain sub authorities!!! */
879 
880  Status = SampOpenDbObject(ServerObject,
881  L"Domains",
882  L"Account",
883  0,
886  &DomainObject);
887  }
888  else
889  {
890  /* No valid domain SID */
892  }
893 
894  if (NT_SUCCESS(Status))
895  *DomainHandle = (SAMPR_HANDLE)DomainObject;
896 
898 
899  TRACE("SamrOpenDomain done (Status 0x%08lx)\n", Status);
900 
901  return Status;
902 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
#define SID_REVISION
Definition: setypes.h:453
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
RTL_RESOURCE SampResource
Definition: samsrv.c:28
static GENERIC_MAPPING DomainMapping
Definition: samrpc.c:24
#define SID_MAX_SUB_AUTHORITIES
Definition: setypes.h:454
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
#define SAM_SERVER_LOOKUP_DOMAIN
Definition: ntsam.h:104
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
static const WCHAR L[]
Definition: oid.c:1250
#define SECURITY_NT_NON_UNIQUE
Definition: setypes.h:549
NTSYSAPI VOID NTAPI RtlMapGenericMask(PACCESS_MASK AccessMask, PGENERIC_MAPPING GenericMapping)
NTSTATUS SampOpenDbObject(IN PSAM_DB_OBJECT ParentObject, IN LPWSTR ContainerName, IN LPWSTR ObjectName, IN ULONG RelativeId, IN SAM_DB_OBJECT_TYPE ObjectType, IN ACCESS_MASK DesiredAccess, OUT PSAM_DB_OBJECT *DbObject)
Definition: database.c:171
void * SAMPR_HANDLE
Definition: authpackage.c:113

◆ SamrOpenUser()

NTSTATUS NTAPI SamrOpenUser ( IN SAMPR_HANDLE  DomainHandle,
IN ACCESS_MASK  DesiredAccess,
IN ULONG  UserId,
OUT SAMPR_HANDLE UserHandle 
)

◆ SamrQueryInformationUser()

NTSTATUS NTAPI SamrQueryInformationUser ( IN SAMPR_HANDLE  UserHandle,
IN USER_INFORMATION_CLASS  UserInformationClass,
OUT PSAMPR_USER_INFO_BUFFER Buffer 
)

Definition at line 7337 of file samrpc.c.

7340 {
7341  PSAM_DB_OBJECT UserObject;
7343  NTSTATUS Status;
7344 
7345  TRACE("SamrQueryInformationUser(%p %lu %p)\n",
7346  UserHandle, UserInformationClass, Buffer);
7347 
7348  switch (UserInformationClass)
7349  {
7351  case UserNameInformation:
7357  break;
7358 
7360  case UserHomeInformation:
7361  case UserScriptInformation:
7365  break;
7366 
7371  break;
7372 
7376  break;
7377 
7378  case UserLogonInformation:
7382  USER_READ_LOGON |
7384  break;
7385 
7388  case UserAllInformation:
7389  DesiredAccess = 0;
7390  break;
7391 
7392  default:
7394  }
7395 
7397  TRUE);
7398 
7399  /* Validate the domain handle */
7400  Status = SampValidateDbObject(UserHandle,
7402  DesiredAccess,
7403  &UserObject);
7404  if (!NT_SUCCESS(Status))
7405  {
7406  TRACE("failed with status 0x%08lx\n", Status);
7407  goto done;
7408  }
7409 
7410  switch (UserInformationClass)
7411  {
7413  Status = SampQueryUserGeneral(UserObject,
7414  Buffer);
7415  break;
7416 
7418  Status = SampQueryUserPreferences(UserObject,
7419  Buffer);
7420  break;
7421 
7422  case UserLogonInformation:
7423  Status = SampQueryUserLogon(UserObject,
7424  Buffer);
7425  break;
7426 
7428  Status = SampQueryUserLogonHours(UserObject,
7429  Buffer);
7430  break;
7431 
7433  Status = SampQueryUserAccount(UserObject,
7434  Buffer);
7435  break;
7436 
7437  case UserNameInformation:
7438  Status = SampQueryUserName(UserObject,
7439  Buffer);
7440  break;
7441 
7443  Status = SampQueryUserAccountName(UserObject,
7444  Buffer);
7445  break;
7446 
7448  Status = SampQueryUserFullName(UserObject,
7449  Buffer);
7450  break;
7451 
7453  Status = SampQueryUserPrimaryGroup(UserObject,
7454  Buffer);
7455  break;
7456 
7457  case UserHomeInformation:
7458  Status = SampQueryUserHome(UserObject,
7459  Buffer);
7460  break;
7461 
7462  case UserScriptInformation:
7463  Status = SampQueryUserScript(UserObject,
7464  Buffer);
7465  break;
7466 
7468  Status = SampQueryUserProfile(UserObject,
7469  Buffer);
7470  break;
7471 
7473  Status = SampQueryUserAdminComment(UserObject,
7474  Buffer);
7475  break;
7476 
7478  Status = SampQueryUserWorkStations(UserObject,
7479  Buffer);
7480  break;
7481 
7483  Status = SampQueryUserControl(UserObject,
7484  Buffer);
7485  break;
7486 
7488  Status = SampQueryUserExpires(UserObject,
7489  Buffer);
7490  break;
7491 
7493  Status = SampQueryUserInternal1(UserObject,
7494  Buffer);
7495  break;
7496 
7498  Status = SampQueryUserInternal2(UserObject,
7499  Buffer);
7500  break;
7501 
7503  Status = SampQueryUserParameters(UserObject,
7504  Buffer);
7505  break;
7506 
7507  case UserAllInformation:
7508  Status = SampQueryUserAll(UserObject,
7509  Buffer);
7510  break;
7511 
7512 // case UserInternal4Information:
7513 // case UserInternal5Information:
7514 // case UserInternal4InformationNew:
7515 // case UserInternal5InformationNew:
7516 
7517  default:
7519  }
7520 
7521 done:
7523 
7524  return Status;
7525 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
static NTSTATUS SampQueryUserFullName(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6289
#define TRUE
Definition: types.h:120
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
static NTSTATUS SampQueryUserInternal1(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6676
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS SampQueryUserPrimaryGroup(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6331
static NTSTATUS SampQueryUserAdminComment(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6508
static NTSTATUS SampQueryUserAccountName(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6248
static NTSTATUS SampQueryUserGeneral(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5650
static NTSTATUS SampQueryUserHome(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6372
static NTSTATUS SampQueryUserExpires(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6633
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
static NTSTATUS SampQueryUserAccount(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5979
static NTSTATUS SampQueryUserInternal2(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6764
RTL_RESOURCE SampResource
Definition: samsrv.c:28
#define USER_READ_GENERAL
Definition: ntsam.h:126
Definition: bufpool.h:45
static NTSTATUS SampQueryUserAll(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6852
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
static NTSTATUS SampQueryUserLogonHours(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6149
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define USER_READ_ACCOUNT
Definition: ntsam.h:130
static NTSTATUS SampQueryUserProfile(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6467
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
static NTSTATUS SampQueryUserPreferences(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5744
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
static NTSTATUS SampQueryUserLogon(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5800
static NTSTATUS SampQueryUserWorkStations(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6549
static NTSTATUS SampQueryUserParameters(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6811
static NTSTATUS SampQueryUserControl(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6591
static NTSTATUS SampQueryUserName(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6194
#define USER_READ_PREFERENCES
Definition: ntsam.h:127
static NTSTATUS SampQueryUserScript(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6426
#define USER_READ_LOGON
Definition: ntsam.h:129
ULONG ACCESS_MASK
Definition: nt_native.h:40

Referenced by LsaApLogonUserEx2(), SamQueryInformationUser(), and SamrQueryInformationUser2().

◆ SamrSetInformationUser()

NTSTATUS NTAPI SamrSetInformationUser ( IN SAMPR_HANDLE  UserHandle,
IN USER_INFORMATION_CLASS  UserInformationClass,
IN PSAMPR_USER_INFO_BUFFER  Buffer 
)

Definition at line 8129 of file samrpc.c.

8132 {
8133  PSAM_DB_OBJECT UserObject;
8135  NTSTATUS Status;
8136 
8137  TRACE("SamrSetInformationUser(%p %lu %p)\n",
8138  UserHandle, UserInformationClass, Buffer);
8139 
8140  switch (UserInformationClass)
8141  {
8143  case UserNameInformation:
8147  case UserHomeInformation:
8148  case UserScriptInformation:
8156  break;
8157 
8161  break;
8162 
8165  break;
8166 
8170  break;
8171 
8172  case UserAllInformation:
8174  DesiredAccess = 0; /* FIXME */
8175  break;
8176 
8177  default:
8179  }
8180 
8182  TRUE);
8183 
8184  /* Validate the domain handle */
8185  Status = SampValidateDbObject(UserHandle,
8187  DesiredAccess,
8188  &UserObject);
8189  if (!NT_SUCCESS(Status))
8190  {
8191  TRACE("failed with status 0x%08lx\n", Status);
8192  goto done;
8193  }
8194 
8195  switch (UserInformationClass)
8196  {
8198  Status = SampSetUserGeneral(UserObject,
8199  Buffer);
8200  break;
8201 
8203  Status = SampSetUserPreferences(UserObject,
8204  Buffer);
8205  break;
8206 
8208  Status = SampSetLogonHoursAttribute(UserObject,
8209  &Buffer->LogonHours.LogonHours);
8210  break;
8211 
8212  case UserNameInformation:
8213  Status = SampSetUserName(UserObject,
8214  &Buffer->Name.UserName);
8215  if (!NT_SUCCESS(Status))
8216  break;
8217 
8218  Status = SampSetObjectAttributeString(UserObject,
8219  L"FullName",
8220  &Buffer->Name.FullName);
8221  break;
8222 
8224  Status = SampSetUserName(UserObject,
8225  &Buffer->AccountName.UserName);
8226  break;
8227 
8229  Status = SampSetObjectAttributeString(UserObject,
8230  L"FullName",
8231  &Buffer->FullName.FullName);
8232  break;
8233 
8235  Status = SampSetUserPrimaryGroup(UserObject,
8236  Buffer);
8237  break;
8238 
8239  case UserHomeInformation:
8240  Status = SampSetObjectAttributeString(UserObject,
8241  L"HomeDirectory",
8242  &Buffer->Home.HomeDirectory);
8243  if (!NT_SUCCESS(Status))
8244  break;
8245 
8246  Status = SampSetObjectAttributeString(UserObject,
8247  L"HomeDirectoryDrive",
8248  &Buffer->Home.HomeDirectoryDrive);
8249  break;
8250 
8251  case UserScriptInformation:
8252  Status = SampSetObjectAttributeString(UserObject,
8253  L"ScriptPath",
8254  &Buffer->Script.ScriptPath);
8255  break;
8256 
8258  Status = SampSetObjectAttributeString(UserObject,
8259  L"ProfilePath",
8260  &Buffer->Profile.ProfilePath);
8261  break;
8262 
8264  Status = SampSetObjectAttributeString(UserObject,
8265  L"AdminComment",
8266  &Buffer->AdminComment.AdminComment);
8267  break;
8268 
8270  Status = SampSetObjectAttributeString(UserObject,
8271  L"WorkStations",
8272  &Buffer->WorkStations.WorkStations);
8273  break;
8274 
8276  TRACE("Password: %S\n", Buffer->SetPassword.Password.Buffer);
8277  TRACE("PasswordExpired: %d\n", Buffer->SetPassword.PasswordExpired);
8278 
8279  Status = SampSetObjectAttributeString(UserObject,
8280  L"Password",
8281  &Buffer->SetPassword.Password);
8282  break;
8283 
8285  Status = SampSetUserControl(UserObject,
8286  Buffer);
8287  break;
8288 
8290  Status = SampSetUserExpires(UserObject,
8291  Buffer);
8292  break;
8293 
8295  Status = SampSetUserInternal1(UserObject,
8296  Buffer);
8297  break;
8298 
8300  Status = SampSetUserInternal2(UserObject,
8301  Buffer);
8302  break;
8303 
8305  Status = SampSetObjectAttributeString(UserObject,
8306  L"Parameters",
8307  &Buffer->Parameters.Parameters);
8308  break;
8309 
8310  case UserAllInformation:
8311  Status = SampSetUserAll(UserObject,
8312  Buffer);
8313  break;
8314 
8315 // case UserInternal4Information:
8316 // case UserInternal5Information:
8317 // case UserInternal4InformationNew:
8318 // case UserInternal5InformationNew:
8319 
8320  default:
8322  }
8323 
8324 done:
8326 
8327  return Status;
8328 }
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
static NTSTATUS SampSetUserControl(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7720
static NTSTATUS SampSetUserInternal1(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7781
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
RTL_RESOURCE SampResource
Definition: samsrv.c:28
static NTSTATUS SampSetUserAll(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7889
#define USER_FORCE_PASSWORD_CHANGE
Definition: ntsam.h:133
Definition: bufpool.h:45
#define USER_WRITE_PREFERENCES
Definition: ntsam.h:128
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static NTSTATUS SampSetUserExpires(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7750
NTSTATUS SampValidateDbObject(SAMPR_HANDLE Handle, SAM_DB_OBJECT_TYPE ObjectType, ACCESS_MASK DesiredAccess, PSAM_DB_OBJECT *DbObject)
Definition: database.c:299
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
static const WCHAR L[]
Definition: oid.c:1250
static NTSTATUS SampSetUserInternal2(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7836
static NTSTATUS SampSetUserName(PSAM_DB_OBJECT UserObject, PRPC_UNICODE_STRING NewUserName)
Definition: samrpc.c:7529
#define USER_WRITE_ACCOUNT
Definition: ntsam.h:131
NTSTATUS SampSetLogonHoursAttribute(IN PSAM_DB_OBJECT UserObject, IN PSAMPR_LOGON_HOURS LogonHours)
Definition: user.c:689
static NTSTATUS SampSetUserPrimaryGroup(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7690
NTSTATUS SampSetObjectAttributeString(PSAM_DB_OBJECT DbObject, LPWSTR AttributeName, PRPC_UNICODE_STRING String)
Definition: database.c:593
static NTSTATUS SampSetUserGeneral(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7600
static NTSTATUS SampSetUserPreferences(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7653
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceExclusive(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)

Referenced by LsaApLogonUserEx2(), SamrSetInformationUser2(), and SamSetInformationUser().

◆ SystemFunction006()

NTSTATUS WINAPI SystemFunction006 ( LPCSTR  password,
LPSTR  hash 
)

Definition at line 53 of file crypt_lmhash.c.

54 {
55  CRYPT_LMhash( (unsigned char*)hash, (const unsigned char*)password, strlen(password) );
56 
57  return STATUS_SUCCESS;
58 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void CRYPT_LMhash(unsigned char *dst, const unsigned char *pwd, const int len)
Definition: crypt_lmhash.c:39
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: _hash_fun.h:40

◆ SystemFunction007()

NTSTATUS WINAPI SystemFunction007 ( PUNICODE_STRING  string,
LPBYTE  hash 
)

◆ SystemFunction012()

NTSTATUS WINAPI SystemFunction012 ( const BYTE in,
const BYTE key,
LPBYTE  out 
)

Definition at line 353 of file sysfunc.c.

354 {
355  if (!in || !out)
356  return STATUS_UNSUCCESSFUL;
357 
358  CRYPT_DEShash(out, key, in);
359  CRYPT_DEShash(out+8, key+7, in+8);
360  return STATUS_SUCCESS;
361 }
static FILE * out
Definition: regtests2xml.c:44
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
GLuint in
Definition: glext.h:9616
unsigned char * CRYPT_DEShash(unsigned char *dst, const unsigned char *key, const unsigned char *src) DECLSPEC_HIDDEN
Definition: crypt_des.c:259
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: path.c:41