Author: ekohl
Date: Sat Sep 29 22:52:30 2012
New Revision: 57438
URL:
http://svn.reactos.org/svn/reactos?rev=57438&view=rev
Log:
[LSASRV]
- Fix a typo: LsarEnmuerateAccountRights --> LsarEnumerateAccountRights.
- Implement LsarEnumeratePrivileges.
Modified:
trunk/reactos/dll/win32/advapi32/sec/lsa.c
trunk/reactos/dll/win32/lsasrv/lsarpc.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
trunk/reactos/dll/win32/lsasrv/privileges.c
trunk/reactos/include/reactos/idl/lsa.idl
Modified: trunk/reactos/dll/win32/advapi32/sec/lsa.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/sec/lsa…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/sec/lsa.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/sec/lsa.c [iso-8859-1] Sat Sep 29 22:52:30 2012
@@ -417,7 +417,7 @@
RpcTryExcept
{
- Status = LsarEnmuerateAccountRights((LSAPR_HANDLE)PolicyHandle,
+ Status = LsarEnumerateAccountRights((LSAPR_HANDLE)PolicyHandle,
AccountSid,
&UserRightsSet);
Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Sat Sep 29 22:52:30 2012
@@ -109,8 +109,26 @@
PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer,
DWORD PreferedMaximumLength)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PLSA_DB_OBJECT PolicyObject;
+ NTSTATUS Status;
+
+ TRACE("LsarEnumeratePrivileges(%p %p %p %lu)\n",
+ PolicyHandle, EnumerationContext, EnumerationBuffer,
+ PreferedMaximumLength);
+
+ Status = LsapValidateDbObject(PolicyHandle,
+ LsaDbPolicyObject,
+ POLICY_VIEW_LOCAL_INFORMATION,
+ &PolicyObject);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ if (EnumerationContext == NULL)
+ return STATUS_INVALID_PARAMETER;
+
+ return LsarpEnumeratePrivileges(EnumerationContext,
+ EnumerationBuffer,
+ PreferedMaximumLength);
}
@@ -1658,7 +1676,7 @@
/* Function 36 */
-NTSTATUS WINAPI LsarEnmuerateAccountRights(
+NTSTATUS WINAPI LsarEnumerateAccountRights(
LSAPR_HANDLE PolicyHandle,
PRPC_SID AccountSid,
PLSAPR_USER_RIGHT_SET UserRights)
@@ -1666,7 +1684,8 @@
PLSA_DB_OBJECT PolicyObject;
NTSTATUS Status;
- FIXME("(%p,%p,%p) stub\n", PolicyHandle, AccountSid, UserRights);
+ TRACE("LsarEnumerateAccountRights(%p %p %p)\n",
+ PolicyHandle, AccountSid, UserRights);
Status = LsapValidateDbObject(PolicyHandle,
LsaDbPolicyObject,
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Sat Sep 29 22:52:30 2012
@@ -182,6 +182,11 @@
LsarpLookupPrivilegeValue(PUNICODE_STRING Name,
PLUID Value);
+NTSTATUS
+LsarpEnumeratePrivileges(DWORD *EnumerationContext,
+ PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer,
+ DWORD PreferedMaximumLength);
+
/* sids.h */
NTSTATUS
LsapInitSids(VOID);
Modified: trunk/reactos/dll/win32/lsasrv/privileges.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/privilege…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/privileges.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/privileges.c [iso-8859-1] Sat Sep 29 22:52:30 2012
@@ -9,6 +9,8 @@
#include "lsasrv.h"
+WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
+
typedef struct
{
@@ -16,6 +18,8 @@
LPCWSTR Name;
} PRIVILEGE_DATA;
+
+/* GLOBALS *****************************************************************/
static const PRIVILEGE_DATA WellKnownPrivileges[] =
{
@@ -111,8 +115,6 @@
{
if (_wcsicmp(Name->Buffer, WellKnownPrivileges[Priv].Name) == 0)
{
-// Value->LowPart = WellKnownPrivileges[Priv].Luid.LowPart;
-// Value->HighPart = WellKnownPrivileges[Priv].Luid.HighPart;
*Value = WellKnownPrivileges[Priv].Luid;
return STATUS_SUCCESS;
}
@@ -120,3 +122,100 @@
return STATUS_NO_SUCH_PRIVILEGE;
}
+
+
+NTSTATUS
+LsarpEnumeratePrivileges(DWORD *EnumerationContext,
+ PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer,
+ DWORD PreferedMaximumLength)
+{
+ PLSAPR_POLICY_PRIVILEGE_DEF Privileges = NULL;
+ ULONG EnumIndex;
+ ULONG EnumCount = 0;
+ ULONG RequiredLength = 0;
+ ULONG i;
+ BOOLEAN MoreEntries = FALSE;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ EnumIndex = *EnumerationContext;
+
+ for (; EnumIndex < sizeof(WellKnownPrivileges) / sizeof(WellKnownPrivileges[0]);
EnumIndex++)
+ {
+ TRACE("EnumIndex: %lu\n", EnumIndex);
+ TRACE("Privilege Name: %S\n", WellKnownPrivileges[EnumIndex].Name);
+ TRACE("Name Length: %lu\n",
wcslen(WellKnownPrivileges[EnumIndex].Name));
+
+ if ((RequiredLength +
+ wcslen(WellKnownPrivileges[EnumIndex].Name) * sizeof(WCHAR) +
+ sizeof(UNICODE_NULL) +
+ sizeof(LSAPR_POLICY_PRIVILEGE_DEF)) > PreferedMaximumLength)
+ {
+ MoreEntries = TRUE;
+ break;
+ }
+
+ RequiredLength += (wcslen(WellKnownPrivileges[EnumIndex].Name) * sizeof(WCHAR) +
+ sizeof(UNICODE_NULL) + sizeof(LSAPR_POLICY_PRIVILEGE_DEF));
+ EnumCount++;
+ }
+
+ TRACE("EnumCount: %lu\n", EnumCount);
+ TRACE("RequiredLength: %lu\n", RequiredLength);
+
+ if (EnumCount == 0)
+ goto done;
+
+ Privileges = MIDL_user_allocate(EnumCount * sizeof(LSAPR_POLICY_PRIVILEGE_DEF));
+ if (Privileges == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ EnumIndex = *EnumerationContext;
+
+ for (i = 0; i < EnumCount; i++, EnumIndex++)
+ {
+ Privileges[i].LocalValue = WellKnownPrivileges[EnumIndex].Luid;
+
+ Privileges[i].Name.Length = (USHORT)wcslen(WellKnownPrivileges[EnumIndex].Name) *
sizeof(WCHAR);
+ Privileges[i].Name.MaximumLength = (USHORT)Privileges[i].Name.Length +
sizeof(UNICODE_NULL);
+
+ Privileges[i].Name.Buffer =
MIDL_user_allocate(Privileges[i].Name.MaximumLength);
+ if (Privileges[i].Name.Buffer == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ memcpy(Privileges[i].Name.Buffer,
+ WellKnownPrivileges[EnumIndex].Name,
+ Privileges[i].Name.Length);
+ }
+
+done:
+ if (NT_SUCCESS(Status))
+ {
+ EnumerationBuffer->Entries = EnumCount;
+ EnumerationBuffer->Privileges = Privileges;
+ *EnumerationContext += EnumCount;
+ }
+ else
+ {
+ if (Privileges != NULL)
+ {
+ for (i = 0; i < EnumCount; i++)
+ {
+ if (Privileges[i].Name.Buffer != NULL)
+ MIDL_user_free(Privileges[i].Name.Buffer);
+ }
+
+ MIDL_user_free(Privileges);
+ }
+ }
+
+ if ((Status == STATUS_SUCCESS) && (MoreEntries == TRUE))
+ Status = STATUS_MORE_ENTRIES;
+
+ return Status;
+}
Modified: trunk/reactos/include/reactos/idl/lsa.idl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/idl/lsa.id…
==============================================================================
--- trunk/reactos/include/reactos/idl/lsa.idl [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/idl/lsa.idl [iso-8859-1] Sat Sep 29 22:52:30 2012
@@ -821,7 +821,7 @@
[out] PLSAPR_ACCOUNT_ENUM_BUFFER EnumerationBuffer);
/* Function 36 */
- NTSTATUS __stdcall LsarEnmuerateAccountRights(
+ NTSTATUS __stdcall LsarEnumerateAccountRights(
[in] LSAPR_HANDLE PolicyHandle,
[in] PRPC_SID AccountSid,
[out] PLSAPR_USER_RIGHT_SET UserRights);