1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Security Account Manager (SAM) Server
4 * FILE: reactos/dll/win32/samsrv/display.c
5 * PURPOSE: Display cache
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10 #include "samsrv.h"
11
12 #include <winuser.h>
13
14 /* GLOBALS *****************************************************************/
15
16 typedef struct _USER_ENTRY
17 {
18 LIST_ENTRY ListEntry;
19 SAMPR_DOMAIN_DISPLAY_USER User;
20 } USER_ENTRY, *PUSER_ENTRY;
21
22
23 static LIST_ENTRY UserListHead;
24 static BOOLEAN UserListFilled = FALSE;
25 static ULONG UserListCount = 0;
26
27 //static LIST_HEAD MachineListHead;
28 //static LIST_HEAD GroupListHead;
29
30
31
32 /* FUNCTIONS ***************************************************************/
33
34 static
35 NTSTATUS
SampFillUserDisplayCache(_In_ PSAM_DB_OBJECT DomainObject)36 SampFillUserDisplayCache(
37 _In_ PSAM_DB_OBJECT DomainObject)
38 {
39 HANDLE UsersKeyHandle = NULL;
40 WCHAR UserKeyName[64];
41 ULONG EnumIndex;
42 ULONG NameLength;
43 ULONG Rid;
44 PSAM_DB_OBJECT UserObject;
45 SAM_USER_FIXED_DATA FixedUserData;
46 ULONG Size;
47 ULONG DataType;
48 PUSER_ENTRY UserEntry;
49 NTSTATUS Status;
50
51 FIXME("SampFillUserDisplayCache(%p)\n", DomainObject);
52
53 if (UserListFilled)
54 {
55 FIXME("Already filled!\n");
56 return STATUS_SUCCESS;
57 }
58
59 Status = SampRegOpenKey(DomainObject->KeyHandle,
60 L"Users",
61 KEY_ALL_ACCESS, /* FIXME */
62 &UsersKeyHandle);
63 if (!NT_SUCCESS(Status))
64 goto done;
65
66 for (EnumIndex = 0; ; EnumIndex++)
67 {
68 FIXME("EnumIndex: %lu\n", EnumIndex);
69 NameLength = 64 * sizeof(WCHAR);
70 Status = SampRegEnumerateSubKey(UsersKeyHandle,
71 EnumIndex,
72 NameLength,
73 UserKeyName);
74 if (!NT_SUCCESS(Status))
75 {
76 if (Status == STATUS_NO_MORE_ENTRIES)
77 Status = STATUS_SUCCESS;
78 break;
79 }
80
81 FIXME("User name: %S\n", UserKeyName);
82 FIXME("Name length: %lu\n", NameLength);
83
84 Rid = wcstoul(UserKeyName, NULL, 16);
85 if (Rid == 0 || Rid == ULONG_MAX)
86 continue;
87
88 FIXME("Rid: 0x%lx\n", Rid);
89 Status = SampOpenDbObject(DomainObject,
90 L"Users",
91 UserKeyName,
92 Rid,
93 SamDbUserObject,
94 0,
95 &UserObject);
96 if (NT_SUCCESS(Status))
97 {
98 Size = sizeof(SAM_USER_FIXED_DATA);
99 Status = SampGetObjectAttribute(UserObject,
100 L"F",
101 &DataType,
102 (LPVOID)&FixedUserData,
103 &Size);
104 if (NT_SUCCESS(Status))
105 {
106 FIXME("Account control: 0x%lx\n", FixedUserData.UserAccountControl);
107
108 if (FixedUserData.UserAccountControl & USER_NORMAL_ACCOUNT)
109 {
110 UserEntry = RtlAllocateHeap(RtlGetProcessHeap(),
111 HEAP_ZERO_MEMORY,
112 sizeof(USER_ENTRY));
113 if (UserEntry != NULL)
114 {
115
116 UserEntry->User.Rid = Rid;
117 UserEntry->User.AccountControl = FixedUserData.UserAccountControl;
118
119 /* FIXME: Add remaining attributes */
120
121 InsertTailList(&UserListHead, &UserEntry->ListEntry);
122 UserListCount++;
123 }
124 }
125 }
126
127 SampCloseDbObject(UserObject);
128 }
129 }
130
131 done:
132 if (Status == STATUS_SUCCESS)
133 UserListFilled = TRUE;
134
135 FIXME("SampFillUserDisplayCache() done (Status 0x%08lx)\n", Status);
136
137 return Status;
138 }
139
140
141
142 NTSTATUS
SampInitializeDisplayCache(VOID)143 SampInitializeDisplayCache(VOID)
144 {
145 TRACE("SampInitializeDisplayCache()\n");
146
147 InitializeListHead(&UserListHead);
148 UserListFilled = FALSE;
149 UserListCount = 0;
150
151 // InitializeListHead(&MachineListHead);
152 // MachineListFilled = FALSE;
153 // MachineListCount = 0;
154
155 // InitializeListHead(&GroupListHead);
156 // GroupListFilled = FALSE;
157 // GroupListCount = 0;
158
159 return STATUS_SUCCESS;
160 }
161
162
163 NTSTATUS
SampShutdownDisplayCache(VOID)164 SampShutdownDisplayCache(VOID)
165 {
166 TRACE("SampShutdownDisplayCache()\n");
167 return STATUS_SUCCESS;
168 }
169
170
171 NTSTATUS
SampFillDisplayCache(_In_ PSAM_DB_OBJECT DomainObject,_In_ DOMAIN_DISPLAY_INFORMATION DisplayInformationClass)172 SampFillDisplayCache(
173 _In_ PSAM_DB_OBJECT DomainObject,
174 _In_ DOMAIN_DISPLAY_INFORMATION DisplayInformationClass)
175 {
176 NTSTATUS Status;
177
178 TRACE("SampFillDisplayCache()\n");
179
180 switch (DisplayInformationClass)
181 {
182 case DomainDisplayUser:
183 Status = SampFillUserDisplayCache(DomainObject);
184 break;
185 /*
186 case DomainDisplayMachine:
187 Status = SampFillMachineDisplayCache(DomainObject);
188 break;
189
190 case DomainDisplayGroup:
191 Status = SampFillGroupDisplayCache(DomainObject);
192 break;
193 */
194 default:
195 Status = STATUS_INVALID_INFO_CLASS;
196 break;
197 }
198
199 return Status;
200 }
201
202 /* EOF */
203