https://git.reactos.org/?p=reactos.git;a=commitdiff;h=df0137a1694a24291594c…
commit df0137a1694a24291594cf3b9aa58168bcd45c9f
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Sep 9 13:39:01 2018 +0200
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Sep 9 13:39:01 2018 +0200
[NETAPI32] Implement NetGroupSetInfo
---
dll/win32/netapi32/group.c | 18 ---
dll/win32/netapi32/group_new.c | 255 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 254 insertions(+), 19 deletions(-)
diff --git a/dll/win32/netapi32/group.c b/dll/win32/netapi32/group.c
index 75c03697bc..b87ab9b83c 100644
--- a/dll/win32/netapi32/group.c
+++ b/dll/win32/netapi32/group.c
@@ -76,24 +76,6 @@ NetGroupGetUsers(IN LPCWSTR servername,
}
-/************************************************************
- * NetGroupSetInfo (NETAPI32.@)
- *
- */
-NET_API_STATUS
-WINAPI
-NetGroupSetInfo(IN LPCWSTR servername,
- IN LPCWSTR groupname,
- IN DWORD level,
- IN LPBYTE buf,
- OUT LPDWORD parm_err)
-{
- FIXME("(%s, %s, %d, %p, %p) stub!\n", debugstr_w(servername),
- debugstr_w(groupname), level, buf, parm_err);
- return ERROR_ACCESS_DENIED;
-}
-
-
/************************************************************
* NetGroupSetUsers (NETAPI32.@)
*
diff --git a/dll/win32/netapi32/group_new.c b/dll/win32/netapi32/group_new.c
index 7adb98b01c..7a9d27185b 100644
--- a/dll/win32/netapi32/group_new.c
+++ b/dll/win32/netapi32/group_new.c
@@ -272,7 +272,7 @@ NetGroupAdd(
_In_opt_ LPCWSTR servername,
_In_ DWORD level,
_In_ LPBYTE buf,
- _Out_ LPDWORD parm_err)
+ _Out_opt_ LPDWORD parm_err)
{
GROUP_ADM_COMMENT_INFORMATION AdminComment;
GROUP_ATTRIBUTE_INFORMATION AttributeInfo;
@@ -875,4 +875,257 @@ done:
return ApiStatus;
}
+
+NET_API_STATUS
+WINAPI
+NetGroupSetInfo(
+ _In_opt_ LPCWSTR servername,
+ _In_ LPCWSTR groupname,
+ _In_ DWORD level,
+ _In_ LPBYTE buf,
+ _Out_opt_ LPDWORD parm_err)
+{
+ UNICODE_STRING ServerName;
+ UNICODE_STRING GroupName;
+ SAM_HANDLE ServerHandle = NULL;
+ SAM_HANDLE DomainHandle = NULL;
+ SAM_HANDLE GroupHandle = NULL;
+ GROUP_NAME_INFORMATION GroupNameInfo;
+ GROUP_ADM_COMMENT_INFORMATION AdminCommentInfo;
+ GROUP_ATTRIBUTE_INFORMATION AttributeInfo;
+ NET_API_STATUS ApiStatus = NERR_Success;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ TRACE("NetGroupSetInfo(%s, %s, %d, %p, %p)\n",
+ debugstr_w(servername), debugstr_w(groupname), level, buf, parm_err);
+
+ if (parm_err != NULL)
+ *parm_err = PARM_ERROR_NONE;
+
+ if (servername != NULL)
+ RtlInitUnicodeString(&ServerName, servername);
+
+ RtlInitUnicodeString(&GroupName, groupname);
+
+ /* Connect to the SAM Server */
+ Status = SamConnect((servername != NULL) ? &ServerName : NULL,
+ &ServerHandle,
+ SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamConnect failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Open the Acount Domain */
+ Status = OpenAccountDomain(ServerHandle,
+ (servername != NULL) ? &ServerName : NULL,
+ DOMAIN_LOOKUP,
+ &DomainHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("OpenAccountDomain failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Open the group */
+ ApiStatus = OpenGroupByName(DomainHandle,
+ &GroupName,
+ GROUP_WRITE_ACCOUNT,
+ &GroupHandle,
+ NULL);
+ if (ApiStatus != NERR_Success)
+ {
+ WARN("OpenGroupByName failed (ApiStatus %lu)\n", ApiStatus);
+ if (ApiStatus == ERROR_NONE_MAPPED)
+ ApiStatus = NERR_GroupNotFound;
+ goto done;
+ }
+
+ switch (level)
+ {
+ case 0:
+ /* Set the group name */
+ RtlInitUnicodeString(&GroupNameInfo.Name,
+ ((PGROUP_INFO_0)buf)->grpi0_name);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupNameInformation,
+ &GroupNameInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+ break;
+
+ case 1:
+ /* Set the group name */
+ RtlInitUnicodeString(&GroupNameInfo.Name,
+ ((PGROUP_INFO_1)buf)->grpi1_name);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupNameInformation,
+ &GroupNameInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Set the admin comment */
+ RtlInitUnicodeString(&AdminCommentInfo.AdminComment,
+ ((PGROUP_INFO_1)buf)->grpi1_comment);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAdminCommentInformation,
+ &AdminCommentInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+ break;
+
+ case 2:
+ /* Set the group name */
+ RtlInitUnicodeString(&GroupNameInfo.Name,
+ ((PGROUP_INFO_2)buf)->grpi2_name);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupNameInformation,
+ &GroupNameInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Set the admin comment */
+ RtlInitUnicodeString(&AdminCommentInfo.AdminComment,
+ ((PGROUP_INFO_2)buf)->grpi2_comment);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAdminCommentInformation,
+ &AdminCommentInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Set the attributes */
+ AttributeInfo.Attributes = ((PGROUP_INFO_2)buf)->grpi2_attributes;
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAttributeInformation,
+ &AttributeInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+ break;
+
+ case 3:
+ /* Set the group name */
+ RtlInitUnicodeString(&GroupNameInfo.Name,
+ ((PGROUP_INFO_3)buf)->grpi3_name);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupNameInformation,
+ &GroupNameInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Set the admin comment */
+ RtlInitUnicodeString(&AdminCommentInfo.AdminComment,
+ ((PGROUP_INFO_3)buf)->grpi3_comment);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAdminCommentInformation,
+ &AdminCommentInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Set the attributes */
+ AttributeInfo.Attributes = ((PGROUP_INFO_3)buf)->grpi3_attributes;
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAttributeInformation,
+ &AttributeInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+ break;
+
+ case 1002:
+ /* Set the admin comment */
+ RtlInitUnicodeString(&AdminCommentInfo.AdminComment,
+ ((PGROUP_INFO_1002)buf)->grpi1002_comment);
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAdminCommentInformation,
+ &AdminCommentInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+ break;
+
+ case 1005:
+ /* Set the attributes */
+ AttributeInfo.Attributes = ((PGROUP_INFO_1005)buf)->grpi1005_attributes;
+
+ Status = SamSetInformationGroup(GroupHandle,
+ GroupAttributeInformation,
+ &AttributeInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamSetInformationGroup failed (ApiStatus %lu)\n",
ApiStatus);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+ break;
+
+ default:
+ ApiStatus = ERROR_INVALID_LEVEL;
+ goto done;
+ }
+
+done:
+ if (GroupHandle != NULL)
+ SamCloseHandle(GroupHandle);
+
+ if (DomainHandle != NULL)
+ SamCloseHandle(DomainHandle);
+
+ if (ServerHandle != NULL)
+ SamCloseHandle(ServerHandle);
+
+ return ApiStatus;
+}
+
/* EOF */