ReactOS  0.4.15-dev-2528-g5506091
domain.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Services
4  * FILE: base/services/wkssvc/domain.c
5  * PURPOSE: Workstation service
6  * PROGRAMMER: Eric Kohl
7  */
8 
9 /* INCLUDES *****************************************************************/
10 
11 #include "precomp.h"
12 
14 
15 /* FUNCTIONS *****************************************************************/
16 
17 static
20  _In_ LPCWSTR lpWorkgroupName)
21 {
23  POLICY_PRIMARY_DOMAIN_INFO PrimaryDomainInfo;
24  LSA_HANDLE PolicyHandle = NULL;
26 
29 
33  &PolicyHandle);
34  if (!LSA_SUCCESS(Status))
36 
37  RtlInitUnicodeString(&PrimaryDomainInfo.Name,
38  lpWorkgroupName);
39  PrimaryDomainInfo.Sid = NULL;
40 
41  Status = LsaSetInformationPolicy(PolicyHandle,
43  &PrimaryDomainInfo);
44 
45  LsaClose(PolicyHandle);
46 
48 }
49 
50 
53  _In_ LPCWSTR lpWorkgroupName)
54 {
56 
57  FIXME("NetpJoinWorkgroup(%S)\n", lpWorkgroupName);
58 
59  status = NetpSetPrimaryDomain(lpWorkgroupName);
60  if (status != NERR_Success)
61  {
62  ERR("NetpSetPrimaryDomain failed (Status %lu)\n", status);
63  return status;
64  }
65 
66  return NERR_Success;
67 }
68 
69 
72  LPWSTR *NameBuffer,
73  PNETSETUP_JOIN_STATUS BufferType)
74 {
76  PPOLICY_PRIMARY_DOMAIN_INFO PrimaryDomainInfo = NULL;
77  LSA_HANDLE PolicyHandle = NULL;
79 
80  *BufferType = NetSetupUnknownStatus;
81  *NameBuffer = NULL;
82 
85 
89  &PolicyHandle);
90  if (!LSA_SUCCESS(Status))
92 
93  Status = LsaQueryInformationPolicy(PolicyHandle,
95  (PVOID*)&PrimaryDomainInfo);
96  if (LSA_SUCCESS(Status))
97  {
98  TRACE("Sid: %p\n", PrimaryDomainInfo->Sid);
99  TRACE("Name: %S\n", PrimaryDomainInfo->Name.Buffer);
100 
101  if (PrimaryDomainInfo->Name.Length > 0)
102  {
103  if (PrimaryDomainInfo->Sid != NULL)
104  *BufferType = NetSetupDomainName;
105  else
106  *BufferType = NetSetupWorkgroupName;
107 
108  *NameBuffer = midl_user_allocate(PrimaryDomainInfo->Name.Length + sizeof(WCHAR));
109  if (*NameBuffer)
110  wcscpy(*NameBuffer, PrimaryDomainInfo->Name.Buffer);
111  }
112  else
113  {
114  *BufferType = NetSetupUnjoined;
115  }
116 
117  if (PrimaryDomainInfo->Sid)
118  LsaFreeMemory(PrimaryDomainInfo->Sid);
119 
120  LsaFreeMemory(PrimaryDomainInfo);
121  }
122 
123  LsaClose(PolicyHandle);
124 
126 }
127 
128 /* EOF */
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSTATUS WINAPI LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, OUT PVOID *Buffer)
Definition: lsa.c:1471
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define midl_user_allocate
Definition: rpc.h:44
#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
#define ZeroMemory
Definition: winbase.h:1664
NTSTATUS WINAPI LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle, IN POLICY_INFORMATION_CLASS InformationClass, IN PVOID Buffer)
Definition: lsa.c:1946
#define NERR_Success
Definition: lmerr.h:5
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
#define FIXME(fmt,...)
Definition: debug.h:111
LSA_UNICODE_STRING Name
Definition: ntsecapi.h:570
NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
Definition: lsa.c:699
#define LSA_SUCCESS(x)
Definition: ntsecapi.h:23
NET_API_STATUS NetpJoinWorkgroup(_In_ LPCWSTR lpWorkgroupName)
Definition: domain.c:52
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
NET_API_STATUS NetpGetJoinInformation(LPWSTR *NameBuffer, PNETSETUP_JOIN_STATUS BufferType)
Definition: domain.c:71
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG WINAPI LsaNtStatusToWinError(IN NTSTATUS Status)
Definition: lsa.c:1129
#define POLICY_TRUST_ADMIN
Definition: ntsecapi.h:64
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
enum _NETSETUP_JOIN_STATUS * PNETSETUP_JOIN_STATUS
struct _LSA_OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES
#define ERR(fmt,...)
Definition: debug.h:110
#define _In_
Definition: no_sal2.h:158
WINE_DEFAULT_DEBUG_CHANNEL(wkssvc)
static NET_API_STATUS NetpSetPrimaryDomain(_In_ LPCWSTR lpWorkgroupName)
Definition: domain.c:19
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97