From 4b858fe42a49cd0eaf496276e497c6483575a7fd Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 24 Dec 2012 12:48:39 +0000 Subject: [PATCH] [NETAPI32] Use servername in NetLocalGroupEnum and NetUserEnum. svn path=/trunk/; revision=57994 --- reactos/dll/win32/netapi32/local_group.c | 9 +++++++-- reactos/dll/win32/netapi32/misc.c | 7 ++++--- reactos/dll/win32/netapi32/netapi32.h | 5 +++-- reactos/dll/win32/netapi32/user.c | 9 +++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/reactos/dll/win32/netapi32/local_group.c b/reactos/dll/win32/netapi32/local_group.c index 46655ca0381..02e07d8b0d4 100644 --- a/reactos/dll/win32/netapi32/local_group.c +++ b/reactos/dll/win32/netapi32/local_group.c @@ -150,6 +150,7 @@ NET_API_STATUS WINAPI NetLocalGroupEnum( LPDWORD totalentries, PDWORD_PTR resumehandle) { + UNICODE_STRING ServerName; PSAM_RID_ENUMERATION CurrentAlias; PENUM_CONTEXT EnumContext = NULL; PSID DomainSid = NULL; @@ -171,6 +172,9 @@ NET_API_STATUS WINAPI NetLocalGroupEnum( *totalentries = 0; *bufptr = NULL; + if (servername != NULL) + RtlInitUnicodeString(&ServerName, servername); + if (resumehandle != NULL && *resumehandle != 0) { EnumContext = (PENUM_CONTEXT)*resumehandle; @@ -187,7 +191,7 @@ NET_API_STATUS WINAPI NetLocalGroupEnum( EnumContext->Index = 0; EnumContext->BuiltinDone = FALSE; - Status = SamConnect(NULL, + Status = SamConnect((servername != NULL) ? &ServerName : NULL, &EnumContext->ServerHandle, SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN, NULL); @@ -198,7 +202,8 @@ NET_API_STATUS WINAPI NetLocalGroupEnum( goto done; } - Status = GetAccountDomainSid(&DomainSid); + Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, + &DomainSid); if (!NT_SUCCESS(Status)) { ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); diff --git a/reactos/dll/win32/netapi32/misc.c b/reactos/dll/win32/netapi32/misc.c index 0a46d559e43..612a0908dae 100644 --- a/reactos/dll/win32/netapi32/misc.c +++ b/reactos/dll/win32/netapi32/misc.c @@ -37,7 +37,8 @@ static SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; /* FUNCTIONS *****************************************************************/ NTSTATUS -GetAccountDomainSid(PSID *AccountDomainSid) +GetAccountDomainSid(IN PUNICODE_STRING ServerName, + OUT PSID *AccountDomainSid) { PPOLICY_ACCOUNT_DOMAIN_INFO AccountDomainInfo = NULL; LSA_OBJECT_ATTRIBUTES ObjectAttributes; @@ -47,7 +48,7 @@ GetAccountDomainSid(PSID *AccountDomainSid) memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES)); - Status = LsaOpenPolicy(NULL, + Status = LsaOpenPolicy(ServerName, &ObjectAttributes, POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle); @@ -89,7 +90,7 @@ done: NTSTATUS -GetBuiltinDomainSid(PSID *BuiltinDomainSid) +GetBuiltinDomainSid(OUT PSID *BuiltinDomainSid) { PSID Sid = NULL; PULONG Ptr; diff --git a/reactos/dll/win32/netapi32/netapi32.h b/reactos/dll/win32/netapi32/netapi32.h index 67f55485567..27e57f6c0cc 100644 --- a/reactos/dll/win32/netapi32/netapi32.h +++ b/reactos/dll/win32/netapi32/netapi32.h @@ -9,9 +9,10 @@ NetpNtStatusToApiStatus(NTSTATUS Status); /* misc.c */ NTSTATUS -GetAccountDomainSid(PSID *AccountDomainSid); +GetAccountDomainSid(IN PUNICODE_STRING ServerName, + OUT PSID *AccountDomainSid); NTSTATUS -GetBuiltinDomainSid(PSID *BuiltinDomainSid); +GetBuiltinDomainSid(OUT PSID *BuiltinDomainSid); #endif \ No newline at end of file diff --git a/reactos/dll/win32/netapi32/user.c b/reactos/dll/win32/netapi32/user.c index 1f6262e48eb..f9bca9ae203 100644 --- a/reactos/dll/win32/netapi32/user.c +++ b/reactos/dll/win32/netapi32/user.c @@ -321,6 +321,7 @@ NetUserEnum(LPCWSTR servername, LPDWORD totalentries, LPDWORD resume_handle) { + UNICODE_STRING ServerName; PSAM_RID_ENUMERATION CurrentUser; PENUM_CONTEXT EnumContext = NULL; LPVOID Buffer = NULL; @@ -346,6 +347,9 @@ NetUserEnum(LPCWSTR servername, *totalentries = 0; *bufptr = NULL; + if (servername != NULL) + RtlInitUnicodeString(&ServerName, servername); + if (resume_handle != NULL && *resume_handle != 0) { EnumContext = (PENUM_CONTEXT)*resume_handle; @@ -362,7 +366,7 @@ NetUserEnum(LPCWSTR servername, EnumContext->Index = 0; EnumContext->BuiltinDone = FALSE; - Status = SamConnect(NULL, + Status = SamConnect((servername != NULL) ? &ServerName : NULL, &EnumContext->ServerHandle, SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN, NULL); @@ -373,7 +377,8 @@ NetUserEnum(LPCWSTR servername, goto done; } - Status = GetAccountDomainSid(&DomainSid); + Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, + &DomainSid); if (!NT_SUCCESS(Status)) { ERR("GetAccountDomainSid failed (Status %08lx)\n", Status);