diff --git a/base/services/wkssvc/domain.c b/base/services/wkssvc/domain.c index 4d39c978fce..69340adfd54 100644 --- a/base/services/wkssvc/domain.c +++ b/base/services/wkssvc/domain.c @@ -66,4 +66,63 @@ NetpJoinWorkgroup( return NERR_Success; } + +NET_API_STATUS +NetpGetJoinInformation( + LPWSTR *NameBuffer, + PNETSETUP_JOIN_STATUS BufferType) +{ + LSA_OBJECT_ATTRIBUTES ObjectAttributes; + PPOLICY_PRIMARY_DOMAIN_INFO PrimaryDomainInfo = NULL; + LSA_HANDLE PolicyHandle = NULL; + NTSTATUS Status; + + *BufferType = NetSetupUnknownStatus; + *NameBuffer = NULL; + + ZeroMemory(&ObjectAttributes, sizeof(LSA_OBJECT_ATTRIBUTES)); + ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES); + + Status = LsaOpenPolicy(NULL, + &ObjectAttributes, + POLICY_VIEW_LOCAL_INFORMATION, + &PolicyHandle); + if (!LSA_SUCCESS(Status)) + return LsaNtStatusToWinError(Status); + + Status = LsaQueryInformationPolicy(PolicyHandle, + PolicyPrimaryDomainInformation, + (PVOID*)&PrimaryDomainInfo); + if (LSA_SUCCESS(Status)) + { + TRACE("Sid: %p\n", PrimaryDomainInfo->Sid); + TRACE("Name: %S\n", PrimaryDomainInfo->Name.Buffer); + + if (PrimaryDomainInfo->Name.Length > 0) + { + if (PrimaryDomainInfo->Sid != NULL) + *BufferType = NetSetupDomainName; + else + *BufferType = NetSetupWorkgroupName; + + *NameBuffer = midl_user_allocate(PrimaryDomainInfo->Name.Length + sizeof(WCHAR)); + if (*NameBuffer) + wcscpy(*NameBuffer, PrimaryDomainInfo->Name.Buffer); + } + else + { + *BufferType = NetSetupUnjoined; + } + + if (PrimaryDomainInfo->Sid) + LsaFreeMemory(PrimaryDomainInfo->Sid); + + LsaFreeMemory(PrimaryDomainInfo); + } + + LsaClose(PolicyHandle); + + return LsaNtStatusToWinError(Status); +} + /* EOF */ diff --git a/base/services/wkssvc/precomp.h b/base/services/wkssvc/precomp.h index c6f841e1eb4..be3c7982465 100644 --- a/base/services/wkssvc/precomp.h +++ b/base/services/wkssvc/precomp.h @@ -28,6 +28,11 @@ NET_API_STATUS NetpJoinWorkgroup( _In_ LPCWSTR WorkgroupName); +NET_API_STATUS +NetpGetJoinInformation( + LPWSTR *NameBuffer, + PNETSETUP_JOIN_STATUS BufferType); + /* rpcserver.c */ diff --git a/base/services/wkssvc/rpcserver.c b/base/services/wkssvc/rpcserver.c index 47f96f8921a..79a062c8ecc 100644 --- a/base/services/wkssvc/rpcserver.c +++ b/base/services/wkssvc/rpcserver.c @@ -364,12 +364,14 @@ NetrGetJoinInformation( wchar_t **NameBuffer, PNETSETUP_JOIN_STATUS BufferType) { - TRACE("NetrGetJoinInformation()\n"); + TRACE("NetrGetJoinInformation(%p %p %p)\n", + ServerName, NameBuffer, BufferType); - *NameBuffer = NULL; - *BufferType = NetSetupUnjoined; + if (NameBuffer == NULL) + return ERROR_INVALID_PARAMETER; - return NERR_Success; + return NetpGetJoinInformation(NameBuffer, + BufferType); } diff --git a/dll/win32/netapi32/wksta.c b/dll/win32/netapi32/wksta.c index 616833c98c1..9200b17aaa0 100644 --- a/dll/win32/netapi32/wksta.c +++ b/dll/win32/netapi32/wksta.c @@ -552,22 +552,3 @@ NET_API_STATUS WINAPI NetWkstaGetInfo( LMSTR servername, DWORD level, } return ret; } - -/************************************************************ - * NetGetJoinInformation (NETAPI32.@) - */ -NET_API_STATUS NET_API_FUNCTION NetGetJoinInformation( - LPCWSTR Server, - LPWSTR *Name, - PNETSETUP_JOIN_STATUS type) -{ - FIXME("Stub %s %p %p\n", wine_dbgstr_w(Server), Name, type); - - if (Name == NULL || type == NULL) - return ERROR_INVALID_PARAMETER; - - *Name = NULL; - *type = NetSetupUnknownStatus; - - return NERR_Success; -} diff --git a/dll/win32/netapi32/wksta_new.c b/dll/win32/netapi32/wksta_new.c index a8eb1da2c84..1853b2052a7 100644 --- a/dll/win32/netapi32/wksta_new.c +++ b/dll/win32/netapi32/wksta_new.c @@ -312,7 +312,6 @@ NetEnumerateComputerNames( } -#if 0 NET_API_STATUS WINAPI NetGetJoinInformation( @@ -342,7 +341,6 @@ NetGetJoinInformation( return status; } -#endif NET_API_STATUS @@ -594,7 +592,7 @@ NetSetPrimaryComputerName( NET_API_STATUS WINAPI NetUnjoinDomain( - _In_ LPCWSTR lpServer, + _In_opt_ LPCWSTR lpServer, _In_opt_ LPCWSTR lpAccount, _In_opt_ LPCWSTR lpPassword, _In_ DWORD fUnjoinOptions)