mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[SAMSRV] Start work on the display cache
Initialize the cache and fill it on demand
This commit is contained in:
parent
556cef5be3
commit
fb8edf90a0
5 changed files with 264 additions and 2 deletions
|
@ -9,6 +9,7 @@ spec2def(samsrv.dll samsrv.spec ADD_IMPORTLIB)
|
|||
list(APPEND SOURCE
|
||||
alias.c
|
||||
database.c
|
||||
display.c
|
||||
domain.c
|
||||
group.c
|
||||
registry.c
|
||||
|
|
202
dll/win32/samsrv/display.c
Normal file
202
dll/win32/samsrv/display.c
Normal file
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: Security Account Manager (SAM) Server
|
||||
* FILE: reactos/dll/win32/samsrv/display.c
|
||||
* PURPOSE: Display cache
|
||||
*
|
||||
* PROGRAMMERS: Eric Kohl
|
||||
*/
|
||||
|
||||
#include "samsrv.h"
|
||||
|
||||
#include <winuser.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
typedef struct _USER_ENTRY
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
SAMPR_DOMAIN_DISPLAY_USER User;
|
||||
} USER_ENTRY, *PUSER_ENTRY;
|
||||
|
||||
|
||||
static LIST_ENTRY UserListHead;
|
||||
static BOOLEAN UserListFilled = FALSE;
|
||||
static ULONG UserListCount = 0;
|
||||
|
||||
//static LIST_HEAD MachineListHead;
|
||||
//static LIST_HEAD GroupListHead;
|
||||
|
||||
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
static
|
||||
NTSTATUS
|
||||
SampFillUserDisplayCache(
|
||||
_In_ PSAM_DB_OBJECT DomainObject)
|
||||
{
|
||||
HANDLE UsersKeyHandle = NULL;
|
||||
WCHAR UserKeyName[64];
|
||||
ULONG EnumIndex;
|
||||
ULONG NameLength;
|
||||
ULONG Rid;
|
||||
PSAM_DB_OBJECT UserObject;
|
||||
SAM_USER_FIXED_DATA FixedUserData;
|
||||
ULONG Size;
|
||||
ULONG DataType;
|
||||
PUSER_ENTRY UserEntry;
|
||||
NTSTATUS Status;
|
||||
|
||||
FIXME("SampFillUserDisplayCache(%p)\n", DomainObject);
|
||||
|
||||
if (UserListFilled)
|
||||
{
|
||||
FIXME("Already filled!\n");
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Status = SampRegOpenKey(DomainObject->KeyHandle,
|
||||
L"Users",
|
||||
KEY_ALL_ACCESS, /* FIXME */
|
||||
&UsersKeyHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
goto done;
|
||||
|
||||
for (EnumIndex = 0; ; EnumIndex++)
|
||||
{
|
||||
FIXME("EnumIndex: %lu\n", EnumIndex);
|
||||
NameLength = 64 * sizeof(WCHAR);
|
||||
Status = SampRegEnumerateSubKey(UsersKeyHandle,
|
||||
EnumIndex,
|
||||
NameLength,
|
||||
UserKeyName);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
FIXME("User name: %S\n", UserKeyName);
|
||||
FIXME("Name length: %lu\n", NameLength);
|
||||
|
||||
Rid = wcstoul(UserKeyName, NULL, 16);
|
||||
if (Rid == 0 || Rid == ULONG_MAX)
|
||||
continue;
|
||||
|
||||
FIXME("Rid: 0x%lx\n", Rid);
|
||||
Status = SampOpenDbObject(DomainObject,
|
||||
L"Users",
|
||||
UserKeyName,
|
||||
Rid,
|
||||
SamDbUserObject,
|
||||
0,
|
||||
&UserObject);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Size = sizeof(SAM_USER_FIXED_DATA);
|
||||
Status = SampGetObjectAttribute(UserObject,
|
||||
L"F",
|
||||
&DataType,
|
||||
(LPVOID)&FixedUserData,
|
||||
&Size);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
FIXME("Account control: 0x%lx\n", FixedUserData.UserAccountControl);
|
||||
|
||||
if (FixedUserData.UserAccountControl & USER_NORMAL_ACCOUNT)
|
||||
{
|
||||
UserEntry = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(USER_ENTRY));
|
||||
if (UserEntry != NULL)
|
||||
{
|
||||
|
||||
UserEntry->User.Rid = Rid;
|
||||
UserEntry->User.AccountControl = FixedUserData.UserAccountControl;
|
||||
|
||||
/* FIXME: Add remaining attributes */
|
||||
|
||||
InsertTailList(&UserListHead, &UserEntry->ListEntry);
|
||||
UserListCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SampCloseDbObject(UserObject);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
if (Status == STATUS_SUCCESS)
|
||||
UserListFilled = TRUE;
|
||||
|
||||
FIXME("SampFillUserDisplayCache() done (Status 0x%08lx)\n", Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NTSTATUS
|
||||
SampInitializeDisplayCache(VOID)
|
||||
{
|
||||
TRACE("SampInitializeDisplayCache()\n");
|
||||
|
||||
InitializeListHead(&UserListHead);
|
||||
UserListFilled = FALSE;
|
||||
UserListCount = 0;
|
||||
|
||||
// InitializeListHead(&MachineListHead);
|
||||
// MachineListFilled = FALSE;
|
||||
// MachineListCount = 0;
|
||||
|
||||
// InitializeListHead(&GroupListHead);
|
||||
// GroupListFilled = FALSE;
|
||||
// GroupListCount = 0;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
SampShutdownDisplayCache(VOID)
|
||||
{
|
||||
TRACE("SampShutdownDisplayCache()\n");
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
SampFillDisplayCache(
|
||||
_In_ PSAM_DB_OBJECT DomainObject,
|
||||
_In_ DOMAIN_DISPLAY_INFORMATION DisplayInformationClass)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
TRACE("SampFillDisplayCache()\n");
|
||||
|
||||
switch (DisplayInformationClass)
|
||||
{
|
||||
case DomainDisplayUser:
|
||||
Status = SampFillUserDisplayCache(DomainObject);
|
||||
break;
|
||||
/*
|
||||
case DomainDisplayMachine:
|
||||
Status = SampFillMachineDisplayCache(DomainObject);
|
||||
break;
|
||||
|
||||
case DomainDisplayGroup:
|
||||
Status = SampFillGroupDisplayCache(DomainObject);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
Status = STATUS_INVALID_INFO_CLASS;
|
||||
break;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -125,6 +125,7 @@ void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
|||
|
||||
void __RPC_USER SAMPR_HANDLE_rundown(SAMPR_HANDLE hHandle)
|
||||
{
|
||||
FIXME("SAMPR_HANDLE_rundown(%p)\n", hHandle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -487,6 +488,12 @@ SamrShutdownSamServer(IN SAMPR_HANDLE ServerHandle)
|
|||
/* Shut the server down */
|
||||
RpcMgmtStopServerListening(0);
|
||||
|
||||
Status = SampShutdownDisplayCache();
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ERR("SampShutdownDisplayCache() failed (Status 0x%08lx)\n", Status);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -9428,12 +9435,42 @@ SamrQueryDisplayInformation3(IN SAMPR_HANDLE DomainHandle,
|
|||
OUT unsigned long *TotalReturned,
|
||||
OUT PSAMPR_DISPLAY_INFO_BUFFER Buffer)
|
||||
{
|
||||
TRACE("SamrQueryDisplayInformation3(%p %lu %lu %lu %lu %p %p %p)\n",
|
||||
PSAM_DB_OBJECT DomainObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
FIXME("SamrQueryDisplayInformation3(%p %lu %lu %lu %lu %p %p %p)\n",
|
||||
DomainHandle, DisplayInformationClass, Index,
|
||||
EntryCount, PreferredMaximumLength, TotalAvailable,
|
||||
TotalReturned, Buffer);
|
||||
|
||||
UNIMPLEMENTED;
|
||||
RtlAcquireResourceShared(&SampResource,
|
||||
TRUE);
|
||||
|
||||
/* Validate the domain handle */
|
||||
Status = SampValidateDbObject(DomainHandle,
|
||||
SamDbDomainObject,
|
||||
DOMAIN_LIST_ACCOUNTS,
|
||||
&DomainObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ERR("SampValidateDbObject() failed (Status 0x%08lx)\n", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Status = SampFillDisplayCache(DomainObject,
|
||||
DisplayInformationClass);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ERR("SampFillDisplayCache() failed (Status 0x%08lx)\n", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
TRACE("returns with status 0x%08lx\n", Status);
|
||||
|
||||
RtlReleaseResource(&SampResource);
|
||||
|
||||
// return Status;
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,10 @@ SamIInitialize(VOID)
|
|||
return Status;
|
||||
}
|
||||
|
||||
Status = SampInitializeDisplayCache();
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
RtlInitializeResource(&SampResource);
|
||||
|
||||
/* Initialize the SAM database */
|
||||
|
|
|
@ -122,6 +122,7 @@ extern ENCRYPTED_LM_OWF_PASSWORD EmptyLmHash;
|
|||
extern RTL_RESOURCE SampResource;
|
||||
extern NT_PRODUCT_TYPE SampProductType;
|
||||
|
||||
|
||||
/* alias.c */
|
||||
|
||||
NTSTATUS
|
||||
|
@ -207,6 +208,21 @@ SampSetObjectAttributeString(PSAM_DB_OBJECT DbObject,
|
|||
LPWSTR AttributeName,
|
||||
PRPC_UNICODE_STRING String);
|
||||
|
||||
|
||||
/* display.c */
|
||||
|
||||
NTSTATUS
|
||||
SampInitializeDisplayCache(VOID);
|
||||
|
||||
NTSTATUS
|
||||
SampShutdownDisplayCache(VOID);
|
||||
|
||||
NTSTATUS
|
||||
SampFillDisplayCache(
|
||||
_In_ PSAM_DB_OBJECT DomainObject,
|
||||
_In_ DOMAIN_DISPLAY_INFORMATION DisplayInformationClass);
|
||||
|
||||
|
||||
/* domain.c */
|
||||
|
||||
NTSTATUS
|
||||
|
@ -233,6 +249,7 @@ SampCreateAccountSid(IN PSAM_DB_OBJECT DomainObject,
|
|||
IN ULONG ulRelativeId,
|
||||
IN OUT PSID *AccountSid);
|
||||
|
||||
|
||||
/* group.h */
|
||||
|
||||
NTSTATUS
|
||||
|
@ -343,6 +360,7 @@ SampCreateUserSD(IN PSID UserSid,
|
|||
OUT PSECURITY_DESCRIPTOR *UserSd,
|
||||
OUT PULONG Size);
|
||||
|
||||
|
||||
/* setup.c */
|
||||
|
||||
BOOL
|
||||
|
|
Loading…
Reference in a new issue