diff --git a/reactos/dll/win32/netapi32/access.c b/reactos/dll/win32/netapi32/access.c index 496f40580ed..4aeea9ffa3f 100644 --- a/reactos/dll/win32/netapi32/access.c +++ b/reactos/dll/win32/netapi32/access.c @@ -18,22 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "lmcons.h" -#include "lmaccess.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "lmuse.h" -#include "ntsecapi.h" -#include "wine/debug.h" -#include "wine/unicode.h" -#include "wine/list.h" +#include "netapi32.h" WINE_DEFAULT_DEBUG_CHANNEL(netapi32); diff --git a/reactos/dll/win32/netapi32/apibuf.c b/reactos/dll/win32/netapi32/apibuf.c index a88c6f4c31c..4a241e23a61 100644 --- a/reactos/dll/win32/netapi32/apibuf.c +++ b/reactos/dll/win32/netapi32/apibuf.c @@ -18,15 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "windef.h" -#include "winbase.h" -#include "lmcons.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "winerror.h" -#include "wine/debug.h" +#include "netapi32.h" WINE_DEFAULT_DEBUG_CHANNEL(netapi32); diff --git a/reactos/dll/win32/netapi32/browsr.c b/reactos/dll/win32/netapi32/browsr.c index 8b0a5ed98a5..80c4b8d080d 100644 --- a/reactos/dll/win32/netapi32/browsr.c +++ b/reactos/dll/win32/netapi32/browsr.c @@ -18,14 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "lmcons.h" -#include "lmbrowsr.h" -#include "lmshare.h" +#include "netapi32.h" /************************************************************ * I_BrowserSetNetlogonState (NETAPI32.@) diff --git a/reactos/dll/win32/netapi32/ds.c b/reactos/dll/win32/netapi32/ds.c index 386e222ca01..0707737895c 100644 --- a/reactos/dll/win32/netapi32/ds.c +++ b/reactos/dll/win32/netapi32/ds.c @@ -18,17 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "ntsecapi.h" -#include "wine/debug.h" -#include "dsrole.h" -#include "dsgetdc.h" +#include "netapi32.h" WINE_DEFAULT_DEBUG_CHANNEL(ds); diff --git a/reactos/dll/win32/netapi32/group.c b/reactos/dll/win32/netapi32/group.c index ea87ee7b56b..b7cd35919ea 100644 --- a/reactos/dll/win32/netapi32/group.c +++ b/reactos/dll/win32/netapi32/group.c @@ -18,22 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "lmcons.h" -#include "lmaccess.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "lmuse.h" -#include "ntsecapi.h" -#include "wine/debug.h" -#include "wine/unicode.h" -#include "wine/list.h" +#include "netapi32.h" WINE_DEFAULT_DEBUG_CHANNEL(netapi32); diff --git a/reactos/dll/win32/netapi32/local_group.c b/reactos/dll/win32/netapi32/local_group.c index d3606a2bc45..cff46d1dfd3 100644 --- a/reactos/dll/win32/netapi32/local_group.c +++ b/reactos/dll/win32/netapi32/local_group.c @@ -18,25 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "lmcons.h" -#include "lmaccess.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "winreg.h" -#include "ntsecapi.h" -#include "wine/debug.h" -#include "wine/unicode.h" - -#define NTOS_MODE_USER -#include -#include "ntsam.h" #include "netapi32.h" WINE_DEFAULT_DEBUG_CHANNEL(netapi32); @@ -232,7 +213,6 @@ NetLocalGroupAdd( SAM_HANDLE ServerHandle = NULL; SAM_HANDLE DomainHandle = NULL; SAM_HANDLE AliasHandle = NULL; - PSID DomainSid = NULL; LPWSTR aliasname = NULL; LPWSTR aliascomment = NULL; ULONG RelativeId; @@ -277,23 +257,13 @@ NetLocalGroupAdd( goto done; } - /* Get the Builtin Domain SID */ - Status = GetBuiltinDomainSid(&DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetBuiltinDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - /* Open the Builtin Domain */ - Status = SamOpenDomain(ServerHandle, - DOMAIN_LOOKUP, - DomainSid, - &DomainHandle); + Status = OpenBuiltinDomain(ServerHandle, + DOMAIN_LOOKUP, + &DomainHandle); if (!NT_SUCCESS(Status)) { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); + ERR("OpenBuiltinDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } @@ -314,29 +284,15 @@ NetLocalGroupAdd( ApiStatus = NERR_Success; - /* Free the Builtin Domain SID */ - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - DomainSid = NULL; - /* Close the Builtin Domain */ SamCloseHandle(DomainHandle); DomainHandle = NULL; - /* Get the account domain SID */ - Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, - &DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - /* Open the account domain */ - Status = SamOpenDomain(ServerHandle, - DOMAIN_CREATE_ALIAS | DOMAIN_LOOKUP, - DomainSid, - &DomainHandle); + Status = OpenAccountDomain(ServerHandle, + (servername != NULL) ? &ServerName : NULL, + DOMAIN_CREATE_ALIAS | DOMAIN_LOOKUP, + &DomainHandle); if (!NT_SUCCESS(Status)) { ERR("SamOpenDomain failed (Status %08lx)\n", Status); @@ -383,9 +339,6 @@ done: if (AliasHandle != NULL) SamCloseHandle(AliasHandle); - if (DomainSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - if (DomainHandle != NULL) SamCloseHandle(DomainHandle); @@ -478,7 +431,6 @@ NET_API_STATUS WINAPI NetLocalGroupEnum( UNICODE_STRING ServerName; PSAM_RID_ENUMERATION CurrentAlias; PENUM_CONTEXT EnumContext = NULL; - PSID DomainSid = NULL; ULONG i; SAM_HANDLE AliasHandle = NULL; PALIAS_GENERAL_INFORMATION AliasInfo = NULL; @@ -523,47 +475,23 @@ NET_API_STATUS WINAPI NetLocalGroupEnum( goto done; } - Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, - &DomainSid); + Status = OpenAccountDomain(EnumContext->ServerHandle, + (servername != NULL) ? &ServerName : NULL, + DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, + &EnumContext->AccountDomainHandle); if (!NT_SUCCESS(Status)) { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); + ERR("OpenAccountDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } - Status = SamOpenDomain(EnumContext->ServerHandle, - DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, - DomainSid, - &EnumContext->AccountDomainHandle); - - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - + Status = OpenBuiltinDomain(EnumContext->ServerHandle, + DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, + &EnumContext->BuiltinDomainHandle); if (!NT_SUCCESS(Status)) { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - - Status = GetBuiltinDomainSid(&DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - - Status = SamOpenDomain(EnumContext->ServerHandle, - DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, - DomainSid, - &EnumContext->BuiltinDomainHandle); - - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - - if (!NT_SUCCESS(Status)) - { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); + ERR("OpenBuiltinDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } @@ -732,7 +660,6 @@ NetLocalGroupGetInfo( SAM_HANDLE ServerHandle = NULL; SAM_HANDLE DomainHandle = NULL; SAM_HANDLE AliasHandle = NULL; - PSID DomainSid = NULL; PALIAS_GENERAL_INFORMATION AliasInfo = NULL; LPVOID Buffer = NULL; NET_API_STATUS ApiStatus = NERR_Success; @@ -758,23 +685,13 @@ NetLocalGroupGetInfo( goto done; } - /* Get the Builtin Domain SID */ - Status = GetBuiltinDomainSid(&DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetBuiltinDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - /* Open the Builtin Domain */ - Status = SamOpenDomain(ServerHandle, - DOMAIN_LOOKUP, - DomainSid, - &DomainHandle); + Status = OpenBuiltinDomain(ServerHandle, + DOMAIN_LOOKUP, + &DomainHandle); if (!NT_SUCCESS(Status)) { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); + ERR("OpenBuiltinDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } @@ -792,30 +709,17 @@ NetLocalGroupGetInfo( if (AliasHandle == NULL) { - if (DomainSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - if (DomainHandle != NULL) SamCloseHandle(DomainHandle); - /* Get the Account Domain SID */ - Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, - &DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - /* Open the Acount Domain */ - Status = SamOpenDomain(ServerHandle, - DOMAIN_LOOKUP, - DomainSid, - &DomainHandle); + Status = OpenAccountDomain(ServerHandle, + (servername != NULL) ? &ServerName : NULL, + DOMAIN_LOOKUP, + &DomainHandle); if (!NT_SUCCESS(Status)) { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); + ERR("OpenAccountDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } @@ -855,9 +759,6 @@ done: if (AliasHandle != NULL) SamCloseHandle(AliasHandle); - if (DomainSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - if (DomainHandle != NULL) SamCloseHandle(DomainHandle); diff --git a/reactos/dll/win32/netapi32/misc.c b/reactos/dll/win32/netapi32/misc.c index 612a0908dae..8a23176ec20 100644 --- a/reactos/dll/win32/netapi32/misc.c +++ b/reactos/dll/win32/netapi32/misc.c @@ -9,20 +9,6 @@ /* INCLUDES ******************************************************************/ -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "lmcons.h" -#include "ntsecapi.h" -#include "wine/debug.h" - -#define NTOS_MODE_USER -#include -#include "ntsam.h" #include "netapi32.h" @@ -125,4 +111,68 @@ done: return Status; } + +NTSTATUS +OpenAccountDomain(IN SAM_HANDLE ServerHandle, + IN PUNICODE_STRING ServerName, + IN ULONG DesiredAccess, + OUT PSAM_HANDLE DomainHandle) +{ + PSID DomainSid = NULL; + NTSTATUS Status; + + Status = GetAccountDomainSid(ServerName, + &DomainSid); + if (!NT_SUCCESS(Status)) + { + ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); + return Status; + } + + Status = SamOpenDomain(ServerHandle, + DesiredAccess, + DomainSid, + DomainHandle); + + RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); + + if (!NT_SUCCESS(Status)) + { + ERR("SamOpenDomain failed (Status %08lx)\n", Status); + } + + return Status; +} + + +NTSTATUS +OpenBuiltinDomain(IN SAM_HANDLE ServerHandle, + IN ULONG DesiredAccess, + OUT PSAM_HANDLE DomainHandle) +{ + PSID DomainSid = NULL; + NTSTATUS Status; + + Status = GetBuiltinDomainSid(&DomainSid); + if (!NT_SUCCESS(Status)) + { + ERR("GetBuiltinDomainSid failed (Status %08lx)\n", Status); + return Status; + } + + Status = SamOpenDomain(ServerHandle, + DesiredAccess, + DomainSid, + DomainHandle); + + RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); + + if (!NT_SUCCESS(Status)) + { + ERR("SamOpenDomain failed (Status %08lx)\n", Status); + } + + return Status; +} + /* EOF */ diff --git a/reactos/dll/win32/netapi32/netapi32.h b/reactos/dll/win32/netapi32/netapi32.h index 27e57f6c0cc..31dea807992 100644 --- a/reactos/dll/win32/netapi32/netapi32.h +++ b/reactos/dll/win32/netapi32/netapi32.h @@ -2,6 +2,32 @@ #ifndef __WINE_NETAPI32_H__ #define __WINE_NETAPI32_H__ +#include + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "windef.h" +#include "winbase.h" +#include "winerror.h" +#include "lmcons.h" +#include "lmaccess.h" +#include "lmapibuf.h" +#include "lmbrowsr.h" +#include "lmerr.h" +#include "lmshare.h" +#include "lmuse.h" +#include "ntsecapi.h" +#include "dsrole.h" +#include "dsgetdc.h" +#include "wine/debug.h" +#include "wine/unicode.h" +#include "wine/list.h" + +#define NTOS_MODE_USER +#include +#include "ntsam.h" + + NET_API_STATUS WINAPI NetpNtStatusToApiStatus(NTSTATUS Status); @@ -15,4 +41,15 @@ GetAccountDomainSid(IN PUNICODE_STRING ServerName, 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); + #endif \ No newline at end of file diff --git a/reactos/dll/win32/netapi32/user.c b/reactos/dll/win32/netapi32/user.c index 20482fa3a0b..3022cc349d3 100644 --- a/reactos/dll/win32/netapi32/user.c +++ b/reactos/dll/win32/netapi32/user.c @@ -18,26 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include - -#include "ntstatus.h" -#define WIN32_NO_STATUS -#include "windef.h" -#include "winbase.h" -#include "winerror.h" -#include "lmcons.h" -#include "lmaccess.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "lmuse.h" -#include "ntsecapi.h" -#include "wine/debug.h" -#include "wine/unicode.h" -#include "wine/list.h" - -#define NTOS_MODE_USER -#include -#include "ntsam.h" #include "netapi32.h" WINE_DEFAULT_DEBUG_CHANNEL(netapi32); @@ -177,7 +157,7 @@ BuildUserInfoBuffer(PUSER_ACCOUNT_INFORMATION UserInfo, if (UserInfo->AdminComment.Length > 0) Size += UserInfo->AdminComment.Length + sizeof(WCHAR); - /* FIXME: Add user comment here */ + /* FIXME: usri10_usr_comment */ if (UserInfo->FullName.Length > 0) Size += UserInfo->FullName.Length + sizeof(WCHAR); @@ -239,9 +219,8 @@ BuildUserInfoBuffer(PUSER_ACCOUNT_INFORMATION UserInfo, UserInfo1->usri1_password = NULL; - UserInfo1->usri1_password_age = 0; /* FIXME */ - - UserInfo1->usri1_priv = 0; /* FIXME */ + /* FIXME: UserInfo1->usri1_password_age */ + /* FIXME: UserInfo1->usri1_priv */ if (UserInfo->HomeDirectory.Length > 0) { @@ -310,7 +289,7 @@ BuildUserInfoBuffer(PUSER_ACCOUNT_INFORMATION UserInfo, Ptr = (LPWSTR)((ULONG_PTR)Ptr + UserInfo->AdminComment.Length + sizeof(WCHAR)); } - /* FIXME: Add user comment here */ + /* FIXME: UserInfo10->usri10_usr_comment */ if (UserInfo->FullName.Length > 0) { @@ -323,7 +302,6 @@ BuildUserInfoBuffer(PUSER_ACCOUNT_INFORMATION UserInfo, } break; - // case 11: case 20: @@ -592,10 +570,7 @@ NetUserEnum(LPCWSTR servername, PSAM_RID_ENUMERATION CurrentUser; PENUM_CONTEXT EnumContext = NULL; LPVOID Buffer = NULL; - PSID DomainSid = NULL; - ULONG i; - SAM_HANDLE UserHandle = NULL; PUSER_ACCOUNT_INFORMATION UserInfo = NULL; @@ -639,47 +614,23 @@ NetUserEnum(LPCWSTR servername, goto done; } - Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, - &DomainSid); + Status = OpenAccountDomain(EnumContext->ServerHandle, + (servername != NULL) ? &ServerName : NULL, + DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, + &EnumContext->AccountDomainHandle); if (!NT_SUCCESS(Status)) { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); + ERR("OpenAccountDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } - Status = SamOpenDomain(EnumContext->ServerHandle, - DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, - DomainSid, - &EnumContext->AccountDomainHandle); - - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - + Status = OpenBuiltinDomain(EnumContext->ServerHandle, + DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, + &EnumContext->BuiltinDomainHandle); if (!NT_SUCCESS(Status)) { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - - Status = GetBuiltinDomainSid(&DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - - Status = SamOpenDomain(EnumContext->ServerHandle, - DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, - DomainSid, - &EnumContext->BuiltinDomainHandle); - - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - - if (!NT_SUCCESS(Status)) - { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); + ERR("OpenBuiltinDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } @@ -871,7 +822,6 @@ NetUserGetInfo(LPCWSTR servername, SAM_HANDLE ServerHandle = NULL; SAM_HANDLE AccountDomainHandle = NULL; SAM_HANDLE UserHandle = NULL; - PSID DomainSid = NULL; PULONG RelativeIds = NULL; PSID_NAME_USE Use = NULL; PUSER_ACCOUNT_INFORMATION UserInfo = NULL; @@ -899,24 +849,14 @@ NetUserGetInfo(LPCWSTR servername, goto done; } - /* Get the Account Domain SID */ - Status = GetAccountDomainSid((servername != NULL) ? &ServerName : NULL, - &DomainSid); - if (!NT_SUCCESS(Status)) - { - ERR("GetAccountDomainSid failed (Status %08lx)\n", Status); - ApiStatus = NetpNtStatusToApiStatus(Status); - goto done; - } - /* Open the Account Domain */ - Status = SamOpenDomain(ServerHandle, - DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, - DomainSid, - &AccountDomainHandle); + Status = OpenAccountDomain(ServerHandle, + (servername != NULL) ? &ServerName : NULL, + DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, + &AccountDomainHandle); if (!NT_SUCCESS(Status)) { - ERR("SamOpenDomain failed (Status %08lx)\n", Status); + ERR("OpenAccountDomain failed (Status %08lx)\n", Status); ApiStatus = NetpNtStatusToApiStatus(Status); goto done; } @@ -989,9 +929,6 @@ done: if (Use != NULL) SamFreeMemory(Use); - if (DomainSid != NULL) - RtlFreeHeap(RtlGetProcessHeap(), 0, DomainSid); - if (AccountDomainHandle != NULL) SamCloseHandle(AccountDomainHandle);