ReactOS  0.4.14-dev-57-g333b8f1
netapi32.h File Reference
#include <wine/config.h>
#include <limits.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <lmaccess.h>
#include <lmapibuf.h>
#include <lmerr.h>
#include <ntsecapi.h>
#include <nb30.h>
#include <iphlpapi.h>
#include <wine/debug.h>
#include <wine/unicode.h>
#include <ndk/rtlfuncs.h>
#include <ntsam.h>
#include "nbnamecache.h"
#include "netbios.h"
Include dependency graph for netapi32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define NTOS_MODE_USER
 

Functions

NTSTATUS GetAccountDomainSid (IN PUNICODE_STRING ServerName, OUT PSID *AccountDomainSid)
 
NTSTATUS GetBuiltinDomainSid (OUT PSID *BuiltinDomainSid)
 
NTSTATUS OpenAccountDomain (IN SAM_HANDLE ServerHandle, IN PUNICODE_STRING ServerName, IN ULONG DesiredAccess, OUT PSAM_HANDLE DomainHandle)
 
NTSTATUS OpenBuiltinDomain (IN SAM_HANDLE ServerHandle, IN ULONG DesiredAccess, OUT SAM_HANDLE *DomainHandle)
 
NET_API_STATUS BuildSidFromSidAndRid (IN PSID SrcSid, IN ULONG RelativeId, OUT PSID *DestSid)
 
VOID CopySidFromSidAndRid (_Out_ PSID DstSid, _In_ PSID SrcSid, _In_ ULONG RelativeId)
 
PSTR WINAPI NetpAllocAnsiStrFromWStr (_In_ PWSTR InString)
 
PSTR WINAPI NetpAllocStrFromWStr (_In_ PWSTR InString)
 
PWSTR WINAPI NetpAllocWStrFromAnsiStr (_In_ PSTR InString)
 
PWSTR WINAPI NetpAllocWStrFromStr (_In_ PSTR InString)
 
PWSTR WINAPI NetpAllocWStrFromWStr (_In_ PWSTR InString)
 
NET_API_STATUS WINAPI NetpNtStatusToApiStatus (_In_ NTSTATUS Status)
 
BOOL NETAPI_IsLocalComputer (LMCSTR ServerName)
 

Variables

LIST_ENTRY g_EnumContextListHead
 
CRITICAL_SECTION g_EnumContextListLock
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 10 of file netapi32.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 11 of file netapi32.h.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 25 of file netapi32.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file netapi32.h.

Function Documentation

◆ BuildSidFromSidAndRid()

NET_API_STATUS BuildSidFromSidAndRid ( IN PSID  SrcSid,
IN ULONG  RelativeId,
OUT PSID DestSid 
)

Definition at line 177 of file utils.c.

180 {
181  UCHAR RidCount;
182  PSID DstSid;
183  ULONG i;
184  ULONG DstSidSize;
185  PULONG p, q;
186  NET_API_STATUS ApiStatus = NERR_Success;
187 
188  RidCount = *RtlSubAuthorityCountSid(SrcSid);
189  if (RidCount >= 8)
191 
192  DstSidSize = RtlLengthRequiredSid(RidCount + 1);
193 
194  ApiStatus = NetApiBufferAllocate(DstSidSize,
195  &DstSid);
196  if (ApiStatus != NERR_Success)
197  return ApiStatus;
198 
199  RtlInitializeSid(DstSid,
201  RidCount + 1);
202 
203  for (i = 0; i < (ULONG)RidCount; i++)
204  {
205  p = RtlSubAuthoritySid(SrcSid, i);
206  q = RtlSubAuthoritySid(DstSid, i);
207  *q = *p;
208  }
209 
210  q = RtlSubAuthoritySid(DstSid, (ULONG)RidCount);
211  *q = RelativeId;
212 
213  *DestSid = DstSid;
214 
215  return NERR_Success;
216 }
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
NTSYSAPI PULONG NTAPI RtlSubAuthoritySid(_In_ PSID Sid, _In_ ULONG SubAuthority)
#define NERR_Success
Definition: lmerr.h:5
NTSYSAPI NTSTATUS NTAPI RtlInitializeSid(IN OUT PSID Sid, IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount)
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
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NTSYSAPI PSID_IDENTIFIER_AUTHORITY NTAPI RtlIdentifierAuthoritySid(PSID Sid)
NTSYSAPI PUCHAR NTAPI RtlSubAuthorityCountSid(IN PSID Sid)
Definition: sid.c:104
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
NTSYSAPI ULONG NTAPI RtlLengthRequiredSid(IN ULONG SubAuthorityCount)
Definition: sid.c:54

Referenced by BuildSidListFromDomainAndName(), GetUserPrivileges(), and NetUserGetLocalGroups().

◆ CopySidFromSidAndRid()

VOID CopySidFromSidAndRid ( _Out_ PSID  DstSid,
_In_ PSID  SrcSid,
_In_ ULONG  RelativeId 
)

Definition at line 220 of file utils.c.

224 {
225  UCHAR RidCount;
226  ULONG i;
227  PULONG p, q;
228 
229  RidCount = *RtlSubAuthorityCountSid(SrcSid);
230  if (RidCount >= 8)
231  return;
232 
233  RtlInitializeSid(DstSid,
235  RidCount + 1);
236 
237  for (i = 0; i < (ULONG)RidCount; i++)
238  {
239  p = RtlSubAuthoritySid(SrcSid, i);
240  q = RtlSubAuthoritySid(DstSid, i);
241  *q = *p;
242  }
243 
244  q = RtlSubAuthoritySid(DstSid, (ULONG)RidCount);
245  *q = RelativeId;
246 }
NTSYSAPI PULONG NTAPI RtlSubAuthoritySid(_In_ PSID Sid, _In_ ULONG SubAuthority)
NTSYSAPI NTSTATUS NTAPI RtlInitializeSid(IN OUT PSID Sid, IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount)
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
NTSYSAPI PSID_IDENTIFIER_AUTHORITY NTAPI RtlIdentifierAuthoritySid(PSID Sid)
NTSYSAPI PUCHAR NTAPI RtlSubAuthorityCountSid(IN PSID Sid)
Definition: sid.c:104
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by BuildUserInfoBuffer().

◆ GetAccountDomainSid()

NTSTATUS GetAccountDomainSid ( IN PUNICODE_STRING  ServerName,
OUT PSID AccountDomainSid 
)

Definition at line 23 of file utils.c.

25 {
26  PPOLICY_ACCOUNT_DOMAIN_INFO AccountDomainInfo = NULL;
28  LSA_HANDLE PolicyHandle = NULL;
29  ULONG Length = 0;
31 
33 
34  Status = LsaOpenPolicy(ServerName,
37  &PolicyHandle);
38  if (!NT_SUCCESS(Status))
39  {
40  ERR("LsaOpenPolicy failed (Status %08lx)\n", Status);
41  return Status;
42  }
43 
44  Status = LsaQueryInformationPolicy(PolicyHandle,
46  (PVOID *)&AccountDomainInfo);
47  if (!NT_SUCCESS(Status))
48  {
49  ERR("LsaQueryInformationPolicy failed (Status %08lx)\n", Status);
50  goto done;
51  }
52 
53  Length = RtlLengthSid(AccountDomainInfo->DomainSid);
54 
55  *AccountDomainSid = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
56  if (*AccountDomainSid == NULL)
57  {
58  ERR("Failed to allocate SID\n");
60  goto done;
61  }
62 
63  memcpy(*AccountDomainSid, AccountDomainInfo->DomainSid, Length);
64 
65 done:
66  if (AccountDomainInfo != NULL)
67  LsaFreeMemory(AccountDomainInfo);
68 
69  LsaClose(PolicyHandle);
70 
71  return Status;
72 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS WINAPI LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PVOID *Buffer)
Definition: lsa.c:1471
#define POLICY_VIEW_LOCAL_INFORMATION
Definition: ntsecapi.h:61
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
Definition: lsa.c:192
NTSTATUS WINAPI LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL, IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes, IN ACCESS_MASK DesiredAccess, OUT PLSA_HANDLE PolicyHandle)
Definition: lsa.c:1181
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:699
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int ULONG
Definition: retypes.h:1
PSID AccountDomainSid
Definition: database.c:22
#define memset(x, y, z)
Definition: compat.h:39

Referenced by OpenAccountDomain().

◆ GetBuiltinDomainSid()

NTSTATUS GetBuiltinDomainSid ( OUT PSID BuiltinDomainSid)

Definition at line 76 of file utils.c.

77 {
78  PSID Sid = NULL;
79  PULONG Ptr;
81 
83 
84  Sid = RtlAllocateHeap(RtlGetProcessHeap(),
85  0,
87  if (Sid == NULL)
89 
91  &NtAuthority,
92  1);
93  if (!NT_SUCCESS(Status))
94  goto done;
95 
98 
100 
101 done:
102  if (!NT_SUCCESS(Status))
103  {
104  if (Sid != NULL)
105  RtlFreeHeap(RtlGetProcessHeap(), 0, Sid);
106  }
107 
108  return Status;
109 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
NTSYSAPI PULONG NTAPI RtlSubAuthoritySid(_In_ PSID Sid, _In_ ULONG SubAuthority)
PSID BuiltinDomainSid
Definition: globals.c:16
NTSYSAPI NTSTATUS NTAPI RtlInitializeSid(IN OUT PSID Sid, IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount)
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1104
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: utils.c:18
Status
Definition: gdiplustypes.h:24
unsigned int * PULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSYSAPI ULONG NTAPI RtlLengthRequiredSid(IN ULONG SubAuthorityCount)
Definition: sid.c:54

Referenced by NetUserEnum(), NetUserGetInfo(), and OpenBuiltinDomain().

◆ NETAPI_IsLocalComputer()

BOOL NETAPI_IsLocalComputer ( LMCSTR  ServerName)

Definition at line 33 of file wksta.c.

34 {
36  DWORD size = sizeof(buf) / sizeof(buf[0]);
37  BOOL ret;
38 
39  if (!name || !name[0]) return TRUE;
40 
42  if (ret && name[0] == '\\' && name[1] == '\\') name += 2;
43  return ret && !strcmpiW( name, buf );
44 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:440
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
Definition: name.c:36

Referenced by NetWkstaGetInfo(), and NetWkstaTransportEnum().

◆ NetpAllocAnsiStrFromWStr()

PSTR WINAPI NetpAllocAnsiStrFromWStr ( _In_ PWSTR  InString)

Definition at line 140 of file misc.c.

142 {
145  ULONG Size;
146  NET_API_STATUS NetStatus;
148 
150 
152  NetStatus = NetApiBufferAllocate(Size,
153  (PVOID*)&AnsiString.Buffer);
154  if (NetStatus != NERR_Success)
155  return NULL;
156 
158  &UnicodeString,
159  FALSE);
160  if (!NT_SUCCESS(Status))
161  {
163  return NULL;
164  }
165 
166  return AnsiString.Buffer;
167 }
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
LONG NTSTATUS
Definition: precomp.h:26
#define NERR_Success
Definition: lmerr.h:5
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by DsGetSiteNameA().

◆ NetpAllocStrFromWStr()

PSTR WINAPI NetpAllocStrFromWStr ( _In_ PWSTR  InString)

Definition at line 172 of file misc.c.

174 {
177  ULONG Size;
178  NET_API_STATUS NetStatus;
180 
182 
184  NetStatus = NetApiBufferAllocate(Size,
185  (PVOID*)&OemString.Buffer);
186  if (NetStatus != NERR_Success)
187  return NULL;
188 
190  &UnicodeString,
191  FALSE);
192  if (!NT_SUCCESS(Status))
193  {
194  NetApiBufferFree(OemString.Buffer);
195  return NULL;
196  }
197 
198  return OemString.Buffer;
199 }
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
LONG NTSTATUS
Definition: precomp.h:26
STRING OEM_STRING
Definition: umtypes.h:203
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
#define NERR_Success
Definition: lmerr.h:5
smooth NULL
Definition: ftsmooth.c:416
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

◆ NetpAllocWStrFromAnsiStr()

PWSTR WINAPI NetpAllocWStrFromAnsiStr ( _In_ PSTR  InString)

Definition at line 204 of file misc.c.

206 {
209  ULONG Size;
210  NET_API_STATUS NetStatus;
212 
213  RtlInitAnsiString(&AnsiString, InString);
214 
216  NetStatus = NetApiBufferAllocate(Size,
217  (PVOID*)&UnicodeString.Buffer);
218  if (NetStatus != NERR_Success)
219  return NULL;
220 
222  &AnsiString,
223  FALSE);
224  if (!NT_SUCCESS(Status))
225  {
227  return NULL;
228  }
229 
230  return UnicodeString.Buffer;
231 }
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
LONG NTSTATUS
Definition: precomp.h:26
#define NERR_Success
Definition: lmerr.h:5
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
smooth NULL
Definition: ftsmooth.c:416
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NTSYSAPI DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING *)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned int ULONG
Definition: retypes.h:1

Referenced by DsAddressToSiteNamesA(), DsAddressToSiteNamesExA(), DsDeregisterDnsHostRecordsA(), DsEnumerateDomainTrustsA(), DsGetDcNameWithAccountA(), DsGetDcSiteCoverageA(), and DsGetSiteNameA().

◆ NetpAllocWStrFromStr()

PWSTR WINAPI NetpAllocWStrFromStr ( _In_ PSTR  InString)

Definition at line 236 of file misc.c.

238 {
241  ULONG Size;
242  NET_API_STATUS NetStatus;
244 
246 
248  NetStatus = NetApiBufferAllocate(Size,
249  (PVOID*)&UnicodeString.Buffer);
250  if (NetStatus != NERR_Success)
251  return NULL;
252 
254  &OemString,
255  FALSE);
256  if (!NT_SUCCESS(Status))
257  {
259  return NULL;
260  }
261 
262  return UnicodeString.Buffer;
263 }
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
*BytesInOemString PCHAR OemString
Definition: rtlfuncs.h:1561
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
LONG NTSTATUS
Definition: precomp.h:26
STRING OEM_STRING
Definition: umtypes.h:203
#define NERR_Success
Definition: lmerr.h:5
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
smooth NULL
Definition: ftsmooth.c:416
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
Status
Definition: gdiplustypes.h:24
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI UINT WINAPI RtlOemStringToUnicodeSize(const STRING *)

◆ NetpAllocWStrFromWStr()

PWSTR WINAPI NetpAllocWStrFromWStr ( _In_ PWSTR  InString)

Definition at line 268 of file misc.c.

270 {
271  PWSTR OutString;
272  ULONG Size;
274 
275  Size = (wcslen(InString) + 1) * sizeof(WCHAR);
277  (PVOID*)&OutString);
278  if (Status != NERR_Success)
279  return NULL;
280 
281  wcscpy(OutString, InString);
282 
283  return OutString;
284 }
NET_API_STATUS WINAPI NetApiBufferAllocate(DWORD ByteCount, LPVOID *Buffer)
Definition: apibuf.c:28
uint16_t * PWSTR
Definition: typedefs.h:54
#define NERR_Success
Definition: lmerr.h:5
smooth NULL
Definition: ftsmooth.c:416
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ NetpNtStatusToApiStatus()

NET_API_STATUS WINAPI NetpNtStatusToApiStatus ( _In_ NTSTATUS  Status)

Definition at line 289 of file misc.c.

291 {
292  NET_API_STATUS ApiStatus;
293 
294  switch (Status)
295  {
296  case STATUS_SUCCESS:
297  ApiStatus = NERR_Success;
298  break;
299 
301  ApiStatus = NERR_BadUsername;
302  break;
303 
305  ApiStatus = NERR_PasswordTooShort;
306  break;
307 
308  default:
309  ApiStatus = RtlNtStatusToDosError(Status);
310  break;
311  }
312 
313  return ApiStatus;
314 }
#define NERR_Success
Definition: lmerr.h:5
#define STATUS_PASSWORD_RESTRICTION
Definition: ntstatus.h:330
#define NERR_PasswordTooShort
Definition: lmerr.h:112
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define STATUS_INVALID_ACCOUNT_NAME
Definition: ntstatus.h:320
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define NERR_BadUsername
Definition: lmerr.h:72

Referenced by BuildSidListFromDomainAndName(), BuildUserInfoBuffer(), GetUserDacl(), GetUserPrivileges(), NetGetDisplayInformationIndex(), NetGroupAdd(), NetGroupAddUser(), NetGroupDel(), NetGroupDelUser(), NetGroupEnum(), NetGroupGetInfo(), NetGroupGetUsers(), NetGroupSetInfo(), NetGroupSetUsers(), NetLocalGroupAdd(), NetLocalGroupAddMembers(), NetLocalGroupDel(), NetLocalGroupDelMembers(), NetLocalGroupEnum(), NetLocalGroupGetInfo(), NetLocalGroupGetMembers(), NetLocalGroupSetInfo(), NetQueryDisplayInformation(), NetRegisterDomainNameChangeNotification(), NetUnregisterDomainNameChangeNotification(), NetUserAdd(), NetUserChangePassword(), NetUserDel(), NetUserEnum(), NetUserGetGroups(), NetUserGetInfo(), NetUserGetLocalGroups(), NetUserModalsGet(), NetUserSetInfo(), OpenAliasByName(), OpenGroupByName(), OpenUserByName(), and SetUserInfo().

◆ OpenAccountDomain()

NTSTATUS OpenAccountDomain ( IN SAM_HANDLE  ServerHandle,
IN PUNICODE_STRING  ServerName,
IN ULONG  DesiredAccess,
OUT PSAM_HANDLE  DomainHandle 
)

Definition at line 113 of file utils.c.

117 {
118  PSID DomainSid = NULL;
120 
121  Status = GetAccountDomainSid(ServerName,
122  &DomainSid);
123  if (!NT_SUCCESS(Status))
124  {
125  ERR("GetAccountDomainSid failed (Status %08lx)\n", Status);
126  return Status;
127  }
128 
129  Status = SamOpenDomain(ServerHandle,
131  DomainSid,
132  DomainHandle);
133 
134  RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid);
135 
136  if (!NT_SUCCESS(Status))
137  {
138  ERR("SamOpenDomain failed (Status %08lx)\n", Status);
139  }
140 
141  return Status;
142 }
NTSTATUS GetAccountDomainSid(IN PUNICODE_STRING ServerName, OUT PSID *AccountDomainSid)
Definition: utils.c:23
NTSTATUS NTAPI SamOpenDomain(IN SAM_HANDLE ServerHandle, IN ACCESS_MASK DesiredAccess, IN PSID DomainId, OUT PSAM_HANDLE DomainHandle)
Definition: samlib.c:1441
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
_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

Referenced by NetGetDisplayInformationIndex(), NetGroupAdd(), NetGroupAddUser(), NetGroupDel(), NetGroupDelUser(), NetGroupEnum(), NetGroupGetInfo(), NetGroupGetUsers(), NetGroupSetInfo(), NetGroupSetUsers(), NetLocalGroupAdd(), NetLocalGroupAddMembers(), NetLocalGroupDel(), NetLocalGroupDelMembers(), NetLocalGroupEnum(), NetLocalGroupGetInfo(), NetLocalGroupGetMembers(), NetLocalGroupSetInfo(), NetQueryDisplayInformation(), NetUserAdd(), NetUserDel(), and NetUserSetInfo().

◆ OpenBuiltinDomain()

Variable Documentation

◆ g_EnumContextListHead

LIST_ENTRY g_EnumContextListHead

Definition at line 56 of file user.c.

Referenced by AllocateEnumContext(), DllMain(), and LookupEnumContext().

◆ g_EnumContextListLock

CRITICAL_SECTION g_EnumContextListLock

Definition at line 57 of file user.c.

Referenced by AllocateEnumContext(), DllMain(), FreeEnumContext(), and LookupEnumContext().