ReactOS  0.4.14-dev-1296-g56aa513
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 }
smooth NULL
Definition: ftsmooth.c:416
void __RPC_USER midl_user_free(void __RPC_FAR *ptr)
Definition: lsasrv.c:346
#define ERR(fmt,...)
Definition: debug.h:109
_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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#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
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#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
Status
Definition: gdiplustypes.h:24
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
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
smooth NULL
Definition: ftsmooth.c:416
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 
655  if (Ptr->Profile.ProfilePath.Buffer != NULL)
656  MIDL_user_free(Ptr->Profile.ProfilePath.Buffer);
657 
659  if (Ptr->AdminComment.AdminComment.Buffer != NULL)
660  MIDL_user_free(Ptr->AdminComment.AdminComment.Buffer);
661  break;
662 
664  if (Ptr->WorkStations.WorkStations.Buffer != NULL)
665  MIDL_user_free(Ptr->WorkStations.WorkStations.Buffer);
666  break;
667 
669  ERR("Information class UserSetPasswordInformation cannot be queried!\n");
670  break;
671 
673  break;
674 
676  break;
677 
679  break;
680 
682  break;
683 
685  if (Ptr->Parameters.Parameters.Buffer != NULL)
686  MIDL_user_free(Ptr->Parameters.Parameters.Buffer);
687  break;
688 
689  case UserAllInformation:
690  if (Ptr->All.UserName.Buffer != NULL)
691  MIDL_user_free(Ptr->All.UserName.Buffer);
692 
693  if (Ptr->All.FullName.Buffer != NULL)
694  MIDL_user_free(Ptr->All.FullName.Buffer);
695 
696  if (Ptr->All.HomeDirectory.Buffer != NULL)
697  MIDL_user_free(Ptr->All.HomeDirectory.Buffer);
698 
699  if (Ptr->All.HomeDirectoryDrive.Buffer != NULL)
700  MIDL_user_free(Ptr->All.HomeDirectoryDrive.Buffer);
701 
702  if (Ptr->All.ScriptPath.Buffer != NULL)
703  MIDL_user_free(Ptr->All.ScriptPath.Buffer);
704 
705  if (Ptr->All.ProfilePath.Buffer != NULL)
706  MIDL_user_free(Ptr->All.ProfilePath.Buffer);
707 
708  if (Ptr->All.AdminComment.Buffer != NULL)
709  MIDL_user_free(Ptr->All.AdminComment.Buffer);
710 
711  if (Ptr->All.WorkStations.Buffer != NULL)
712  MIDL_user_free(Ptr->All.WorkStations.Buffer);
713 
714  if (Ptr->All.UserComment.Buffer != NULL)
715  MIDL_user_free(Ptr->All.UserComment.Buffer);
716 
717  if (Ptr->All.Parameters.Buffer != NULL)
718  MIDL_user_free(Ptr->All.Parameters.Buffer);
719 
720  if (Ptr->All.LmOwfPassword.Buffer != NULL)
721  MIDL_user_free(Ptr->All.LmOwfPassword.Buffer);
722 
723  if (Ptr->All.NtOwfPassword.Buffer != NULL)
724  MIDL_user_free(Ptr->All.NtOwfPassword.Buffer);
725 
726  if (Ptr->All.PrivateData.Buffer != NULL)
727  MIDL_user_free(Ptr->All.PrivateData.Buffer);
728 
729  if (Ptr->All.SecurityDescriptor.SecurityDescriptor != NULL)
730  MIDL_user_free(Ptr->All.SecurityDescriptor.SecurityDescriptor);
731 
732  if (Ptr->All.LogonHours.LogonHours != NULL)
733  MIDL_user_free(Ptr->All.LogonHours.LogonHours);
734  break;
735 
736  default:
737  FIXME("Unsupported information class: %lu\n", InformationClass);
738  break;
739  }
740 
742 }
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define ERR(fmt,...)
Definition: debug.h:109
_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 8333 of file samrpc.c.

8344 {
8345  ENCRYPTED_LM_OWF_PASSWORD StoredLmPassword;
8346  ENCRYPTED_NT_OWF_PASSWORD StoredNtPassword;
8347  LM_OWF_PASSWORD OldLmPassword;
8348  LM_OWF_PASSWORD NewLmPassword;
8349  NT_OWF_PASSWORD OldNtPassword;
8350  NT_OWF_PASSWORD NewNtPassword;
8351  BOOLEAN StoredLmPresent = FALSE;
8352  BOOLEAN StoredNtPresent = FALSE;
8353  BOOLEAN StoredLmEmpty = TRUE;
8354  BOOLEAN StoredNtEmpty = TRUE;
8355  PSAM_DB_OBJECT UserObject;
8356  ULONG Length;
8357  SAM_USER_FIXED_DATA UserFixedData;
8358  SAM_DOMAIN_FIXED_DATA DomainFixedData;
8359  LARGE_INTEGER SystemTime;
8360  NTSTATUS Status;
8361 
8362  DBG_UNREFERENCED_LOCAL_VARIABLE(StoredLmPresent);
8363  DBG_UNREFERENCED_LOCAL_VARIABLE(StoredNtPresent);
8364  DBG_UNREFERENCED_LOCAL_VARIABLE(StoredLmEmpty);
8365 
8366  TRACE("SamrChangePasswordUser(%p %u %p %p %u %p %p %u %p %u %p)\n",
8367  UserHandle, LmPresent, OldLmEncryptedWithNewLm, NewLmEncryptedWithOldLm,
8368  NtPresent, OldNtEncryptedWithNewNt, NewNtEncryptedWithOldNt, NtCrossEncryptionPresent,
8369  NewNtEncryptedWithNewLm, LmCrossEncryptionPresent, NewLmEncryptedWithNewNt);
8370 
8372  TRUE);
8373 
8374  /* Validate the user handle */
8375  Status = SampValidateDbObject(UserHandle,
8378  &UserObject);
8379  if (!NT_SUCCESS(Status))
8380  {
8381  TRACE("SampValidateDbObject failed with status 0x%08lx\n", Status);
8382  goto done;
8383  }
8384 
8385  /* Get the current time */
8386  Status = NtQuerySystemTime(&SystemTime);
8387  if (!NT_SUCCESS(Status))
8388  {
8389  TRACE("NtQuerySystemTime failed (Status 0x%08lx)\n", Status);
8390  goto done;
8391  }
8392 
8393  /* Retrieve the LM password */
8395  Status = SampGetObjectAttribute(UserObject,
8396  L"LMPwd",
8397  NULL,
8398  &StoredLmPassword,
8399  &Length);
8400  if (NT_SUCCESS(Status))
8401  {
8402  if (Length == sizeof(ENCRYPTED_LM_OWF_PASSWORD))
8403  {
8404  StoredLmPresent = TRUE;
8405  if (!RtlEqualMemory(&StoredLmPassword,
8406  &EmptyLmHash,
8407  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8408  StoredLmEmpty = FALSE;
8409  }
8410  }
8411 
8412  /* Retrieve the NT password */
8414  Status = SampGetObjectAttribute(UserObject,
8415  L"NTPwd",
8416  NULL,
8417  &StoredNtPassword,
8418  &Length);
8419  if (NT_SUCCESS(Status))
8420  {
8421  if (Length == sizeof(ENCRYPTED_NT_OWF_PASSWORD))
8422  {
8423  StoredNtPresent = TRUE;
8424  if (!RtlEqualMemory(&StoredNtPassword,
8425  &EmptyNtHash,
8426  sizeof(ENCRYPTED_NT_OWF_PASSWORD)))
8427  StoredNtEmpty = FALSE;
8428  }
8429  }
8430 
8431  /* Retrieve the fixed size user data */
8432  Length = sizeof(SAM_USER_FIXED_DATA);
8433  Status = SampGetObjectAttribute(UserObject,
8434  L"F",
8435  NULL,
8436  &UserFixedData,
8437  &Length);
8438  if (!NT_SUCCESS(Status))
8439  {
8440  TRACE("SampGetObjectAttribute failed to retrieve the fixed user data (Status 0x%08lx)\n", Status);
8441  goto done;
8442  }
8443 
8444  /* Check if we can change the password at this time */
8445  if ((StoredLmEmpty == FALSE) || (StoredNtEmpty == FALSE))
8446  {
8447  /* Get fixed domain data */
8448  Length = sizeof(SAM_DOMAIN_FIXED_DATA);
8450  L"F",
8451  NULL,
8452  &DomainFixedData,
8453  &Length);
8454  if (!NT_SUCCESS(Status))
8455  {
8456  TRACE("SampGetObjectAttribute failed to retrieve the fixed domain data (Status 0x%08lx)\n", Status);
8457  goto done;
8458  }
8459 
8460  if (DomainFixedData.MinPasswordAge.QuadPart > 0)
8461  {
8462  if (SystemTime.QuadPart < (UserFixedData.PasswordLastSet.QuadPart + DomainFixedData.MinPasswordAge.QuadPart))
8463  {
8465  goto done;
8466  }
8467  }
8468  }
8469 
8470  /* Decrypt the LM passwords, if present */
8471  if (LmPresent)
8472  {
8473  Status = SystemFunction013((const BYTE *)NewLmEncryptedWithOldLm,
8474  (const BYTE *)&StoredLmPassword,
8475  (LPBYTE)&NewLmPassword);
8476  if (!NT_SUCCESS(Status))
8477  {
8478  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8479  goto done;
8480  }
8481 
8482  Status = SystemFunction013((const BYTE *)OldLmEncryptedWithNewLm,
8483  (const BYTE *)&NewLmPassword,
8484  (LPBYTE)&OldLmPassword);
8485  if (!NT_SUCCESS(Status))
8486  {
8487  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8488  goto done;
8489  }
8490  }
8491 
8492  /* Decrypt the NT passwords, if present */
8493  if (NtPresent)
8494  {
8495  Status = SystemFunction013((const BYTE *)NewNtEncryptedWithOldNt,
8496  (const BYTE *)&StoredNtPassword,
8497  (LPBYTE)&NewNtPassword);
8498  if (!NT_SUCCESS(Status))
8499  {
8500  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8501  goto done;
8502  }
8503 
8504  Status = SystemFunction013((const BYTE *)OldNtEncryptedWithNewNt,
8505  (const BYTE *)&NewNtPassword,
8506  (LPBYTE)&OldNtPassword);
8507  if (!NT_SUCCESS(Status))
8508  {
8509  TRACE("SystemFunction013 failed (Status 0x%08lx)\n", Status);
8510  goto done;
8511  }
8512  }
8513 
8514  /* Check if the old passwords match the stored ones */
8515  if (NtPresent)
8516  {
8517  if (LmPresent)
8518  {
8519  if (!RtlEqualMemory(&StoredLmPassword,
8520  &OldLmPassword,
8521  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8522  {
8523  TRACE("Old LM Password does not match!\n");
8525  }
8526  else
8527  {
8528  if (!RtlEqualMemory(&StoredNtPassword,
8529  &OldNtPassword,
8530  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8531  {
8532  TRACE("Old NT Password does not match!\n");
8534  }
8535  }
8536  }
8537  else
8538  {
8539  if (!RtlEqualMemory(&StoredNtPassword,
8540  &OldNtPassword,
8541  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8542  {
8543  TRACE("Old NT Password does not match!\n");
8545  }
8546  }
8547  }
8548  else
8549  {
8550  if (LmPresent)
8551  {
8552  if (!RtlEqualMemory(&StoredLmPassword,
8553  &OldLmPassword,
8554  sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
8555  {
8556  TRACE("Old LM Password does not match!\n");
8558  }
8559  }
8560  else
8561  {
8563  }
8564  }
8565 
8566  /* Store the new password hashes */
8567  if (NT_SUCCESS(Status))
8568  {
8569  Status = SampSetUserPassword(UserObject,
8570  &NewNtPassword,
8571  NtPresent,
8572  &NewLmPassword,
8573  LmPresent);
8574  if (NT_SUCCESS(Status))
8575  {
8576  /* Update PasswordLastSet */
8577  UserFixedData.PasswordLastSet.QuadPart = SystemTime.QuadPart;
8578 
8579  /* Set the fixed size user data */
8580  Length = sizeof(SAM_USER_FIXED_DATA);
8581  Status = SampSetObjectAttribute(UserObject,
8582  L"F",
8583  REG_BINARY,
8584  &UserFixedData,
8585  Length);
8586  }
8587  }
8588 
8590  {
8591  /* Update BadPasswordCount and LastBadPasswordTime */
8592  UserFixedData.BadPasswordCount++;
8593  UserFixedData.LastBadPasswordTime.QuadPart = SystemTime.QuadPart;
8594 
8595  /* Set the fixed size user data */
8596  Length = sizeof(SAM_USER_FIXED_DATA);
8597  Status = SampSetObjectAttribute(UserObject,
8598  L"F",
8599  REG_BINARY,
8600  &UserFixedData,
8601  Length);
8602  }
8603 
8604 done:
8606 
8607  return Status;
8608 }
#define STATUS_WRONG_PASSWORD
Definition: ntstatus.h:328
#define TRUE
Definition: types.h:120
struct _SAM_USER_FIXED_DATA SAM_USER_FIXED_DATA
struct _SAM_DOMAIN_FIXED_DATA SAM_DOMAIN_FIXED_DATA
#define REG_BINARY
Definition: nt_native.h:1496
#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:332
struct _ENCRYPTED_LM_OWF_PASSWORD ENCRYPTED_LM_OWF_PASSWORD
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
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
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:326
#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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
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: mem.h:68
Status
Definition: gdiplustypes.h:24
ENCRYPTED_LM_OWF_PASSWORD EmptyLmHash
Definition: samsrv.c:27
USHORT BadPasswordCount
Definition: samsrv.h:111
struct _SAM_DB_OBJECT * ParentObject
Definition: samsrv.h:55
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:113
#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
smooth NULL
Definition: ftsmooth.c:416
#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
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938

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 }
#define TRUE
Definition: types.h:120
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
#define KEY_READ
Definition: nt_native.h:1023
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:445
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
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define SAM_SERVER_LOOKUP_DOMAIN
Definition: ntsam.h:104
return Found
Definition: dirsup.c:1270
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS SampRegEnumerateSubKey(IN HANDLE KeyHandle, IN ULONG Index, IN ULONG Length, OUT LPWSTR Buffer)
Definition: registry.c:101
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h: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
Status
Definition: gdiplustypes.h:24
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
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:2938
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 TRUE
Definition: types.h:120
#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
NTSYSAPI BOOLEAN NTAPI RtlAcquireResourceShared(_In_ PRTL_RESOURCE Resource, _In_ BOOLEAN Wait)
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
#define STATUS_NONE_MAPPED
Definition: ntstatus.h:337
RTL_RESOURCE SampResource
Definition: samsrv.c:28
NTSTATUS SampRegCloseKey(IN OUT PHANDLE KeyHandle)
Definition: registry.c:26
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
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#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
Status
Definition: gdiplustypes.h:24
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
NTSTATUS SampRegOpenKey(IN HANDLE ParentKeyHandle, IN LPCWSTR KeyName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE KeyHandle)
Definition: registry.c:158
unsigned int ULONG
Definition: retypes.h:1
#define DOMAIN_LOOKUP
Definition: ntsam.h:42
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
return STATUS_SUCCESS
Definition: btrfs.c:2938
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 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#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
#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
Status
Definition: gdiplustypes.h:24
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
#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 
7461  case UserScriptInformation:
7462  Status = SampQueryUserScript(UserObject,
7463  Buffer);
7464  break;
7465 
7467  Status = SampQueryUserProfile(UserObject,
7468  Buffer);
7469  break;
7470 
7472  Status = SampQueryUserAdminComment(UserObject,
7473  Buffer);
7474  break;
7475 
7477  Status = SampQueryUserWorkStations(UserObject,
7478  Buffer);
7479  break;
7480 
7482  Status = SampQueryUserControl(UserObject,
7483  Buffer);
7484  break;
7485 
7487  Status = SampQueryUserExpires(UserObject,
7488  Buffer);
7489  break;
7490 
7492  Status = SampQueryUserInternal1(UserObject,
7493  Buffer);
7494  break;
7495 
7497  Status = SampQueryUserInternal2(UserObject,
7498  Buffer);
7499  break;
7500 
7502  Status = SampQueryUserParameters(UserObject,
7503  Buffer);
7504  break;
7505 
7506  case UserAllInformation:
7507  Status = SampQueryUserAll(UserObject,
7508  Buffer);
7509  break;
7510 
7511 // case UserInternal4Information:
7512 // case UserInternal5Information:
7513 // case UserInternal4InformationNew:
7514 // case UserInternal5InformationNew:
7515 
7516  default:
7518  }
7519 
7520 done:
7522 
7523  return Status;
7524 }
#define TRUE
Definition: types.h:120
static NTSTATUS SampQueryUserFullName(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6289
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
#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:226
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
Status
Definition: gdiplustypes.h:24
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
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
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 8128 of file samrpc.c.

8131 {
8132  PSAM_DB_OBJECT UserObject;
8134  NTSTATUS Status;
8135 
8136  TRACE("SamrSetInformationUser(%p %lu %p)\n",
8137  UserHandle, UserInformationClass, Buffer);
8138 
8139  switch (UserInformationClass)
8140  {
8142  case UserNameInformation:
8146  case UserHomeInformation:
8147  case UserScriptInformation:
8155  break;
8156 
8160  break;
8161 
8164  break;
8165 
8169  break;
8170 
8171  case UserAllInformation:
8173  DesiredAccess = 0; /* FIXME */
8174  break;
8175 
8176  default:
8178  }
8179 
8181  TRUE);
8182 
8183  /* Validate the domain handle */
8184  Status = SampValidateDbObject(UserHandle,
8186  DesiredAccess,
8187  &UserObject);
8188  if (!NT_SUCCESS(Status))
8189  {
8190  TRACE("failed with status 0x%08lx\n", Status);
8191  goto done;
8192  }
8193 
8194  switch (UserInformationClass)
8195  {
8197  Status = SampSetUserGeneral(UserObject,
8198  Buffer);
8199  break;
8200 
8202  Status = SampSetUserPreferences(UserObject,
8203  Buffer);
8204  break;
8205 
8207  Status = SampSetLogonHoursAttribute(UserObject,
8208  &Buffer->LogonHours.LogonHours);
8209  break;
8210 
8211  case UserNameInformation:
8212  Status = SampSetUserName(UserObject,
8213  &Buffer->Name.UserName);
8214  if (!NT_SUCCESS(Status))
8215  break;
8216 
8217  Status = SampSetObjectAttributeString(UserObject,
8218  L"FullName",
8219  &Buffer->Name.FullName);
8220  break;
8221 
8223  Status = SampSetUserName(UserObject,
8224  &Buffer->AccountName.UserName);
8225  break;
8226 
8228  Status = SampSetObjectAttributeString(UserObject,
8229  L"FullName",
8230  &Buffer->FullName.FullName);
8231  break;
8232 
8234  Status = SampSetUserPrimaryGroup(UserObject,
8235  Buffer);
8236  break;
8237 
8238  case UserHomeInformation:
8239  Status = SampSetObjectAttributeString(UserObject,
8240  L"HomeDirectory",
8241  &Buffer->Home.HomeDirectory);
8242  if (!NT_SUCCESS(Status))
8243  break;
8244 
8245  Status = SampSetObjectAttributeString(UserObject,
8246  L"HomeDirectoryDrive",
8247  &Buffer->Home.HomeDirectoryDrive);
8248  break;
8249 
8250  case UserScriptInformation:
8251  Status = SampSetObjectAttributeString(UserObject,
8252  L"ScriptPath",
8253  &Buffer->Script.ScriptPath);
8254  break;
8255 
8257  Status = SampSetObjectAttributeString(UserObject,
8258  L"ProfilePath",
8259  &Buffer->Profile.ProfilePath);
8260  break;
8261 
8263  Status = SampSetObjectAttributeString(UserObject,
8264  L"AdminComment",
8265  &Buffer->AdminComment.AdminComment);
8266  break;
8267 
8269  Status = SampSetObjectAttributeString(UserObject,
8270  L"WorkStations",
8271  &Buffer->WorkStations.WorkStations);
8272  break;
8273 
8275  TRACE("Password: %S\n", Buffer->SetPassword.Password.Buffer);
8276  TRACE("PasswordExpired: %d\n", Buffer->SetPassword.PasswordExpired);
8277 
8278  Status = SampSetObjectAttributeString(UserObject,
8279  L"Password",
8280  &Buffer->SetPassword.Password);
8281  break;
8282 
8284  Status = SampSetUserControl(UserObject,
8285  Buffer);
8286  break;
8287 
8289  Status = SampSetUserExpires(UserObject,
8290  Buffer);
8291  break;
8292 
8294  Status = SampSetUserInternal1(UserObject,
8295  Buffer);
8296  break;
8297 
8299  Status = SampSetUserInternal2(UserObject,
8300  Buffer);
8301  break;
8302 
8304  Status = SampSetObjectAttributeString(UserObject,
8305  L"Parameters",
8306  &Buffer->Parameters.Parameters);
8307  break;
8308 
8309  case UserAllInformation:
8310  Status = SampSetUserAll(UserObject,
8311  Buffer);
8312  break;
8313 
8314 // case UserInternal4Information:
8315 // case UserInternal5Information:
8316 // case UserInternal4InformationNew:
8317 // case UserInternal5InformationNew:
8318 
8319  default:
8321  }
8322 
8323 done:
8325 
8326  return Status;
8327 }
#define TRUE
Definition: types.h:120
static NTSTATUS SampSetUserControl(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7719
static NTSTATUS SampSetUserInternal1(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7780
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:7888
#define USER_FORCE_PASSWORD_CHANGE
Definition: ntsam.h:133
Definition: bufpool.h:45
#define USER_WRITE_PREFERENCES
Definition: ntsam.h:128
#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:7749
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:226
static const WCHAR L[]
Definition: oid.c:1250
static NTSTATUS SampSetUserInternal2(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7835
Status
Definition: gdiplustypes.h:24
static NTSTATUS SampSetUserName(PSAM_DB_OBJECT UserObject, PRPC_UNICODE_STRING NewUserName)
Definition: samrpc.c:7528
#define USER_WRITE_ACCOUNT
Definition: ntsam.h:131
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK DesiredAccess
Definition: create.c:4157
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:7689
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:7599
static NTSTATUS SampSetUserPreferences(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7652
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
return STATUS_SUCCESS
Definition: btrfs.c:2938
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
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: path.c:41