ReactOS  0.4.13-dev-79-gcd489d8
msv1_0.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <ndk/cmfuncs.h>
#include <ndk/kefuncs.h>
#include <ndk/lpctypes.h>
#include <ndk/lpcfuncs.h>
#include <ndk/mmfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/psfuncs.h>
#include <ndk/rtlfuncs.h>
#include <ndk/setypes.h>
#include <ndk/sefuncs.h>
#include <sspi.h>
#include <ntsecapi.h>
#include <ntsecpkg.h>
#include <ntsam.h>
#include <ntlsa.h>
#include <samsrv/samsrv.h>
#include <wine/debug.h>
Include dependency graph for msv1_0.h:
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 WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define NTOS_MODE_USER
 
#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

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 10 of file msv1_0.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 11 of file msv1_0.h.

◆ FIXUP_POINTER

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

Definition at line 40 of file msv1_0.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 16 of file msv1_0.h.

◆ USER_LOGON_BAD_PASSWORD

#define USER_LOGON_BAD_PASSWORD   0x08000000

Definition at line 97 of file msv1_0.h.

◆ USER_LOGON_SUCCESS

#define USER_LOGON_SUCCESS   0x10000000

Definition at line 98 of file msv1_0.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file msv1_0.h.

Typedef Documentation

◆ ENCRYPTED_LM_OWF_PASSWORD

◆ ENCRYPTED_NT_OWF_PASSWORD

◆ LSAPR_HANDLE

Definition at line 260 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 58 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 59 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:260
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 8324 of file samrpc.c.

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

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:2725
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 3558 of file samrpc.c.

3563 {
3564  PSAM_DB_OBJECT DomainObject;
3565  HANDLE AccountsKeyHandle = NULL;
3566  HANDLE NamesKeyHandle = NULL;
3567  ULONG MappedCount = 0;
3568  ULONG DataLength;
3569  ULONG i;
3570  ULONG RelativeId;
3571  NTSTATUS Status;
3572 
3573  TRACE("SamrLookupNamesInDomain(%p %lu %p %p %p)\n",
3574  DomainHandle, Count, Names, RelativeIds, Use);
3575 
3577  TRUE);
3578 
3579  /* Validate the domain handle */
3580  Status = SampValidateDbObject(DomainHandle,
3582  DOMAIN_LOOKUP,
3583  &DomainObject);
3584  if (!NT_SUCCESS(Status))
3585  {
3586  TRACE("failed with status 0x%08lx\n", Status);
3587  goto done;
3588  }
3589 
3590  RelativeIds->Count = 0;
3591  Use->Count = 0;
3592 
3593  if (Count == 0)
3594  {
3596  goto done;
3597  }
3598 
3599  /* Allocate the relative IDs array */
3600  RelativeIds->Element = midl_user_allocate(Count * sizeof(ULONG));
3601  if (RelativeIds->Element == NULL)
3602  {
3604  goto done;
3605  }
3606 
3607  /* Allocate the use array */
3608  Use->Element = midl_user_allocate(Count * sizeof(ULONG));
3609  if (Use->Element == NULL)
3610  {
3612  goto done;
3613  }
3614 
3615  RelativeIds->Count = Count;
3616  Use->Count = Count;
3617 
3618  for (i = 0; i < Count; i++)
3619  {
3620  TRACE("Name: %S\n", Names[i].Buffer);
3621 
3622  RelativeId = 0;
3623 
3624  /* Lookup aliases */
3625  Status = SampRegOpenKey(DomainObject->KeyHandle,
3626  L"Aliases",
3627  KEY_READ,
3628  &AccountsKeyHandle);
3629  if (NT_SUCCESS(Status))
3630  {
3631  Status = SampRegOpenKey(AccountsKeyHandle,
3632  L"Names",
3633  KEY_READ,
3634  &NamesKeyHandle);
3635  if (NT_SUCCESS(Status))
3636  {
3637  DataLength = sizeof(ULONG);
3638  Status = SampRegQueryValue(NamesKeyHandle,
3639  Names[i].Buffer,
3640  NULL,
3641  &RelativeId,
3642  &DataLength);
3643 
3644  SampRegCloseKey(&NamesKeyHandle);
3645  }
3646 
3647  SampRegCloseKey(&AccountsKeyHandle);
3648  }
3649 
3651  break;
3652 
3653  /* Return alias account */
3654  if (NT_SUCCESS(Status) && RelativeId != 0)
3655  {
3656  TRACE("Rid: %lu\n", RelativeId);
3657  RelativeIds->Element[i] = RelativeId;
3658  Use->Element[i] = SidTypeAlias;
3659  MappedCount++;
3660  continue;
3661  }
3662 
3663  /* Lookup groups */
3664  Status = SampRegOpenKey(DomainObject->KeyHandle,
3665  L"Groups",
3666  KEY_READ,
3667  &AccountsKeyHandle);
3668  if (NT_SUCCESS(Status))
3669  {
3670  Status = SampRegOpenKey(AccountsKeyHandle,
3671  L"Names",
3672  KEY_READ,
3673  &NamesKeyHandle);
3674  if (NT_SUCCESS(Status))
3675  {
3676  DataLength = sizeof(ULONG);
3677  Status = SampRegQueryValue(NamesKeyHandle,
3678  Names[i].Buffer,
3679  NULL,
3680  &RelativeId,
3681  &DataLength);
3682 
3683  SampRegCloseKey(&NamesKeyHandle);
3684  }
3685 
3686  SampRegCloseKey(&AccountsKeyHandle);
3687  }
3688 
3690  break;
3691 
3692  /* Return group account */
3693  if (NT_SUCCESS(Status) && RelativeId != 0)
3694  {
3695  TRACE("Rid: %lu\n", RelativeId);
3696  RelativeIds->Element[i] = RelativeId;
3697  Use->Element[i] = SidTypeGroup;
3698  MappedCount++;
3699  continue;
3700  }
3701 
3702  /* Lookup users */
3703  Status = SampRegOpenKey(DomainObject->KeyHandle,
3704  L"Users",
3705  KEY_READ,
3706  &AccountsKeyHandle);
3707  if (NT_SUCCESS(Status))
3708  {
3709  Status = SampRegOpenKey(AccountsKeyHandle,
3710  L"Names",
3711  KEY_READ,
3712  &NamesKeyHandle);
3713  if (NT_SUCCESS(Status))
3714  {
3715  DataLength = sizeof(ULONG);
3716  Status = SampRegQueryValue(NamesKeyHandle,
3717  Names[i].Buffer,
3718  NULL,
3719  &RelativeId,
3720  &DataLength);
3721 
3722  SampRegCloseKey(&NamesKeyHandle);
3723  }
3724 
3725  SampRegCloseKey(&AccountsKeyHandle);
3726  }
3727 
3729  break;
3730 
3731  /* Return user account */
3732  if (NT_SUCCESS(Status) && RelativeId != 0)
3733  {
3734  TRACE("Rid: %lu\n", RelativeId);
3735  RelativeIds->Element[i] = RelativeId;
3736  Use->Element[i] = SidTypeUser;
3737  MappedCount++;
3738  continue;
3739  }
3740 
3741  /* Return unknown account */
3742  RelativeIds->Element[i] = 0;
3743  Use->Element[i] = SidTypeUnknown;
3744  }
3745 
3746 done:
3749 
3750  if (NT_SUCCESS(Status))
3751  {
3752  if (MappedCount == 0)
3754  else if (MappedCount < Count)
3756  }
3757  else
3758  {
3759  if (RelativeIds->Element != NULL)
3760  {
3761  midl_user_free(RelativeIds->Element);
3762  RelativeIds->Element = NULL;
3763  }
3764 
3765  RelativeIds->Count = 0;
3766 
3767  if (Use->Element != NULL)
3768  {
3769  midl_user_free(Use->Element);
3770  Use->Element = NULL;
3771  }
3772 
3773  Use->Count = 0;
3774  }
3775 
3777 
3778  TRACE("Returned Status %lx\n", Status);
3779 
3780  return Status;
3781 }
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:2725
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 7328 of file samrpc.c.

7331 {
7332  PSAM_DB_OBJECT UserObject;
7334  NTSTATUS Status;
7335 
7336  TRACE("SamrQueryInformationUser(%p %lu %p)\n",
7337  UserHandle, UserInformationClass, Buffer);
7338 
7339  switch (UserInformationClass)
7340  {
7342  case UserNameInformation:
7348  break;
7349 
7351  case UserHomeInformation:
7352  case UserScriptInformation:
7356  break;
7357 
7362  break;
7363 
7367  break;
7368 
7369  case UserLogonInformation:
7373  USER_READ_LOGON |
7375  break;
7376 
7379  case UserAllInformation:
7380  DesiredAccess = 0;
7381  break;
7382 
7383  default:
7385  }
7386 
7388  TRUE);
7389 
7390  /* Validate the domain handle */
7391  Status = SampValidateDbObject(UserHandle,
7393  DesiredAccess,
7394  &UserObject);
7395  if (!NT_SUCCESS(Status))
7396  {
7397  TRACE("failed with status 0x%08lx\n", Status);
7398  goto done;
7399  }
7400 
7401  switch (UserInformationClass)
7402  {
7404  Status = SampQueryUserGeneral(UserObject,
7405  Buffer);
7406  break;
7407 
7409  Status = SampQueryUserPreferences(UserObject,
7410  Buffer);
7411  break;
7412 
7413  case UserLogonInformation:
7414  Status = SampQueryUserLogon(UserObject,
7415  Buffer);
7416  break;
7417 
7419  Status = SampQueryUserLogonHours(UserObject,
7420  Buffer);
7421  break;
7422 
7424  Status = SampQueryUserAccount(UserObject,
7425  Buffer);
7426  break;
7427 
7428  case UserNameInformation:
7429  Status = SampQueryUserName(UserObject,
7430  Buffer);
7431  break;
7432 
7434  Status = SampQueryUserAccountName(UserObject,
7435  Buffer);
7436  break;
7437 
7439  Status = SampQueryUserFullName(UserObject,
7440  Buffer);
7441  break;
7442 
7444  Status = SampQueryUserPrimaryGroup(UserObject,
7445  Buffer);
7446  break;
7447 
7448  case UserHomeInformation:
7449  Status = SampQueryUserHome(UserObject,
7450  Buffer);
7451 
7452  case UserScriptInformation:
7453  Status = SampQueryUserScript(UserObject,
7454  Buffer);
7455  break;
7456 
7458  Status = SampQueryUserProfile(UserObject,
7459  Buffer);
7460  break;
7461 
7463  Status = SampQueryUserAdminComment(UserObject,
7464  Buffer);
7465  break;
7466 
7468  Status = SampQueryUserWorkStations(UserObject,
7469  Buffer);
7470  break;
7471 
7473  Status = SampQueryUserControl(UserObject,
7474  Buffer);
7475  break;
7476 
7478  Status = SampQueryUserExpires(UserObject,
7479  Buffer);
7480  break;
7481 
7483  Status = SampQueryUserInternal1(UserObject,
7484  Buffer);
7485  break;
7486 
7488  Status = SampQueryUserInternal2(UserObject,
7489  Buffer);
7490  break;
7491 
7493  Status = SampQueryUserParameters(UserObject,
7494  Buffer);
7495  break;
7496 
7497  case UserAllInformation:
7498  Status = SampQueryUserAll(UserObject,
7499  Buffer);
7500  break;
7501 
7502 // case UserInternal4Information:
7503 // case UserInternal5Information:
7504 // case UserInternal4InformationNew:
7505 // case UserInternal5InformationNew:
7506 
7507  default:
7509  }
7510 
7511 done:
7513 
7514  return Status;
7515 }
#define TRUE
Definition: types.h:120
static NTSTATUS SampQueryUserFullName(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6280
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:6667
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS SampQueryUserPrimaryGroup(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6322
static NTSTATUS SampQueryUserAdminComment(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6499
static NTSTATUS SampQueryUserAccountName(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6239
static NTSTATUS SampQueryUserGeneral(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5641
static NTSTATUS SampQueryUserHome(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6363
static NTSTATUS SampQueryUserExpires(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6624
NTSYSAPI VOID NTAPI RtlReleaseResource(_In_ PRTL_RESOURCE Resource)
static NTSTATUS SampQueryUserAccount(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5970
static NTSTATUS SampQueryUserInternal2(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6755
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:6843
#define TRACE(s)
Definition: solgame.cpp:4
static NTSTATUS SampQueryUserLogonHours(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6140
#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:6458
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:5735
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:226
static NTSTATUS SampQueryUserLogon(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:5791
static NTSTATUS SampQueryUserWorkStations(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6540
Status
Definition: gdiplustypes.h:24
static NTSTATUS SampQueryUserParameters(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6802
static NTSTATUS SampQueryUserControl(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6582
_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:6185
#define USER_READ_PREFERENCES
Definition: ntsam.h:127
static NTSTATUS SampQueryUserScript(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer)
Definition: samrpc.c:6417
#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 8119 of file samrpc.c.

8122 {
8123  PSAM_DB_OBJECT UserObject;
8125  NTSTATUS Status;
8126 
8127  TRACE("SamrSetInformationUser(%p %lu %p)\n",
8128  UserHandle, UserInformationClass, Buffer);
8129 
8130  switch (UserInformationClass)
8131  {
8133  case UserNameInformation:
8137  case UserHomeInformation:
8138  case UserScriptInformation:
8146  break;
8147 
8151  break;
8152 
8155  break;
8156 
8160  break;
8161 
8162  case UserAllInformation:
8164  DesiredAccess = 0; /* FIXME */
8165  break;
8166 
8167  default:
8169  }
8170 
8172  TRUE);
8173 
8174  /* Validate the domain handle */
8175  Status = SampValidateDbObject(UserHandle,
8177  DesiredAccess,
8178  &UserObject);
8179  if (!NT_SUCCESS(Status))
8180  {
8181  TRACE("failed with status 0x%08lx\n", Status);
8182  goto done;
8183  }
8184 
8185  switch (UserInformationClass)
8186  {
8188  Status = SampSetUserGeneral(UserObject,
8189  Buffer);
8190  break;
8191 
8193  Status = SampSetUserPreferences(UserObject,
8194  Buffer);
8195  break;
8196 
8198  Status = SampSetLogonHoursAttribute(UserObject,
8199  &Buffer->LogonHours.LogonHours);
8200  break;
8201 
8202  case UserNameInformation:
8203  Status = SampSetUserName(UserObject,
8204  &Buffer->Name.UserName);
8205  if (!NT_SUCCESS(Status))
8206  break;
8207 
8208  Status = SampSetObjectAttributeString(UserObject,
8209  L"FullName",
8210  &Buffer->Name.FullName);
8211  break;
8212 
8214  Status = SampSetUserName(UserObject,
8215  &Buffer->AccountName.UserName);
8216  break;
8217 
8219  Status = SampSetObjectAttributeString(UserObject,
8220  L"FullName",
8221  &Buffer->FullName.FullName);
8222  break;
8223 
8225  Status = SampSetUserPrimaryGroup(UserObject,
8226  Buffer);
8227  break;
8228 
8229  case UserHomeInformation:
8230  Status = SampSetObjectAttributeString(UserObject,
8231  L"HomeDirectory",
8232  &Buffer->Home.HomeDirectory);
8233  if (!NT_SUCCESS(Status))
8234  break;
8235 
8236  Status = SampSetObjectAttributeString(UserObject,
8237  L"HomeDirectoryDrive",
8238  &Buffer->Home.HomeDirectoryDrive);
8239  break;
8240 
8241  case UserScriptInformation:
8242  Status = SampSetObjectAttributeString(UserObject,
8243  L"ScriptPath",
8244  &Buffer->Script.ScriptPath);
8245  break;
8246 
8248  Status = SampSetObjectAttributeString(UserObject,
8249  L"ProfilePath",
8250  &Buffer->Profile.ProfilePath);
8251  break;
8252 
8254  Status = SampSetObjectAttributeString(UserObject,
8255  L"AdminComment",
8256  &Buffer->AdminComment.AdminComment);
8257  break;
8258 
8260  Status = SampSetObjectAttributeString(UserObject,
8261  L"WorkStations",
8262  &Buffer->WorkStations.WorkStations);
8263  break;
8264 
8266  TRACE("Password: %S\n", Buffer->SetPassword.Password.Buffer);
8267  TRACE("PasswordExpired: %d\n", Buffer->SetPassword.PasswordExpired);
8268 
8269  Status = SampSetObjectAttributeString(UserObject,
8270  L"Password",
8271  &Buffer->SetPassword.Password);
8272  break;
8273 
8275  Status = SampSetUserControl(UserObject,
8276  Buffer);
8277  break;
8278 
8280  Status = SampSetUserExpires(UserObject,
8281  Buffer);
8282  break;
8283 
8285  Status = SampSetUserInternal1(UserObject,
8286  Buffer);
8287  break;
8288 
8290  Status = SampSetUserInternal2(UserObject,
8291  Buffer);
8292  break;
8293 
8295  Status = SampSetObjectAttributeString(UserObject,
8296  L"Parameters",
8297  &Buffer->Parameters.Parameters);
8298  break;
8299 
8300  case UserAllInformation:
8301  Status = SampSetUserAll(UserObject,
8302  Buffer);
8303  break;
8304 
8305 // case UserInternal4Information:
8306 // case UserInternal5Information:
8307 // case UserInternal4InformationNew:
8308 // case UserInternal5InformationNew:
8309 
8310  default:
8312  }
8313 
8314 done:
8316 
8317  return Status;
8318 }
#define TRUE
Definition: types.h:120
static NTSTATUS SampSetUserControl(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7710
static NTSTATUS SampSetUserInternal1(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7771
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:7879
#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:7740
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:7826
Status
Definition: gdiplustypes.h:24
static NTSTATUS SampSetUserName(PSAM_DB_OBJECT UserObject, PRPC_UNICODE_STRING NewUserName)
Definition: samrpc.c:7519
#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:7680
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:7590
static NTSTATUS SampSetUserPreferences(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER Buffer)
Definition: samrpc.c:7643
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:2725
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:2725
Definition: path.c:42