1c2c66affSColin Finck /*
2c2c66affSColin Finck * SAM Server DLL
3c2c66affSColin Finck * Copyright (C) 2005 Eric Kohl
4c2c66affSColin Finck *
5c2c66affSColin Finck * This program is free software; you can redistribute it and/or modify
6c2c66affSColin Finck * it under the terms of the GNU General Public License as published by
7c2c66affSColin Finck * the Free Software Foundation; either version 2 of the License, or
8c2c66affSColin Finck * (at your option) any later version.
9c2c66affSColin Finck *
10c2c66affSColin Finck * This program is distributed in the hope that it will be useful,
11c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
12c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13c2c66affSColin Finck * GNU General Public License for more details.
14c2c66affSColin Finck *
15c2c66affSColin Finck * You should have received a copy of the GNU General Public License along
16c2c66affSColin Finck * with this program; if not, write to the Free Software Foundation, Inc.,
17c2c66affSColin Finck * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18c2c66affSColin Finck */
19c2c66affSColin Finck
20c2c66affSColin Finck #include "samsrv.h"
21c2c66affSColin Finck
22c2c66affSColin Finck #include <samsrv/samsrv.h>
23c2c66affSColin Finck
24c2c66affSColin Finck /* GLOBALS *******************************************************************/
25c2c66affSColin Finck
26c2c66affSColin Finck ENCRYPTED_NT_OWF_PASSWORD EmptyNtHash;
27c2c66affSColin Finck ENCRYPTED_LM_OWF_PASSWORD EmptyLmHash;
28c2c66affSColin Finck RTL_RESOURCE SampResource;
2954d6fab0SEric Kohl NT_PRODUCT_TYPE SampProductType;
30c2c66affSColin Finck
31c2c66affSColin Finck
32c2c66affSColin Finck /* FUNCTIONS *****************************************************************/
33c2c66affSColin Finck
34c2c66affSColin Finck static
35c2c66affSColin Finck NTSTATUS
SampInitHashes(VOID)36c2c66affSColin Finck SampInitHashes(VOID)
37c2c66affSColin Finck {
38c2c66affSColin Finck UNICODE_STRING EmptyNtPassword = {0, 0, NULL};
39c2c66affSColin Finck CHAR EmptyLmPassword[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
40c2c66affSColin Finck NTSTATUS Status;
41c2c66affSColin Finck
42c2c66affSColin Finck /* Calculate the NT hash value of the empty password */
43c2c66affSColin Finck Status = SystemFunction007(&EmptyNtPassword,
44c2c66affSColin Finck (LPBYTE)&EmptyNtHash);
45c2c66affSColin Finck if (!NT_SUCCESS(Status))
46c2c66affSColin Finck {
47c2c66affSColin Finck ERR("Calculation of the empty NT hash failed (Status 0x%08lx)\n", Status);
48c2c66affSColin Finck return Status;
49c2c66affSColin Finck }
50c2c66affSColin Finck
51c2c66affSColin Finck /* Calculate the LM hash value of the empty password */
52c2c66affSColin Finck Status = SystemFunction006(EmptyLmPassword,
53c2c66affSColin Finck (LPSTR)&EmptyLmHash);
54c2c66affSColin Finck if (!NT_SUCCESS(Status))
55c2c66affSColin Finck {
56c2c66affSColin Finck ERR("Calculation of the empty LM hash failed (Status 0x%08lx)\n", Status);
57c2c66affSColin Finck }
58c2c66affSColin Finck
59c2c66affSColin Finck return Status;
60c2c66affSColin Finck }
61c2c66affSColin Finck
62c2c66affSColin Finck
63c2c66affSColin Finck NTSTATUS
64c2c66affSColin Finck NTAPI
SamIConnect(IN PSAMPR_SERVER_NAME ServerName,OUT SAMPR_HANDLE * ServerHandle,IN ACCESS_MASK DesiredAccess,IN BOOLEAN Trusted)65c2c66affSColin Finck SamIConnect(IN PSAMPR_SERVER_NAME ServerName,
66c2c66affSColin Finck OUT SAMPR_HANDLE *ServerHandle,
67c2c66affSColin Finck IN ACCESS_MASK DesiredAccess,
68c2c66affSColin Finck IN BOOLEAN Trusted)
69c2c66affSColin Finck {
70c2c66affSColin Finck PSAM_DB_OBJECT ServerObject;
71c2c66affSColin Finck NTSTATUS Status;
72c2c66affSColin Finck
73c2c66affSColin Finck TRACE("SamIConnect(%p %p %lx %ld)\n",
74c2c66affSColin Finck ServerName, ServerHandle, DesiredAccess, Trusted);
75c2c66affSColin Finck
76c2c66affSColin Finck /* Map generic access rights */
77c2c66affSColin Finck RtlMapGenericMask(&DesiredAccess,
78c2c66affSColin Finck pServerMapping);
79c2c66affSColin Finck
80c2c66affSColin Finck /* Open the Server Object */
81c2c66affSColin Finck Status = SampOpenDbObject(NULL,
82c2c66affSColin Finck NULL,
83c2c66affSColin Finck L"SAM",
84c2c66affSColin Finck 0,
85c2c66affSColin Finck SamDbServerObject,
86c2c66affSColin Finck DesiredAccess,
87c2c66affSColin Finck &ServerObject);
88c2c66affSColin Finck if (NT_SUCCESS(Status))
89c2c66affSColin Finck {
90c2c66affSColin Finck ServerObject->Trusted = Trusted;
91c2c66affSColin Finck *ServerHandle = (SAMPR_HANDLE)ServerObject;
92c2c66affSColin Finck }
93c2c66affSColin Finck
94c2c66affSColin Finck TRACE("SamIConnect done (Status 0x%08lx)\n", Status);
95c2c66affSColin Finck
96c2c66affSColin Finck return Status;
97c2c66affSColin Finck }
98c2c66affSColin Finck
99c2c66affSColin Finck
100c2c66affSColin Finck NTSTATUS
101c2c66affSColin Finck NTAPI
SamIInitialize(VOID)102c2c66affSColin Finck SamIInitialize(VOID)
103c2c66affSColin Finck {
104c2c66affSColin Finck NTSTATUS Status = STATUS_SUCCESS;
105c2c66affSColin Finck
106c2c66affSColin Finck TRACE("SamIInitialize() called\n");
107c2c66affSColin Finck
10854d6fab0SEric Kohl Status = RtlGetNtProductType(&SampProductType);
10954d6fab0SEric Kohl if (!NT_SUCCESS(Status))
11054d6fab0SEric Kohl SampProductType = NtProductWinNt;
11154d6fab0SEric Kohl
112c2c66affSColin Finck Status = SampInitHashes();
113c2c66affSColin Finck if (!NT_SUCCESS(Status))
114c2c66affSColin Finck return Status;
115c2c66affSColin Finck
116c2c66affSColin Finck if (SampIsSetupRunning())
117c2c66affSColin Finck {
118c2c66affSColin Finck Status = SampInitializeRegistry();
119c2c66affSColin Finck if (!NT_SUCCESS(Status))
120c2c66affSColin Finck return Status;
121c2c66affSColin Finck }
122c2c66affSColin Finck
123*fb8edf90SEric Kohl Status = SampInitializeDisplayCache();
124*fb8edf90SEric Kohl if (!NT_SUCCESS(Status))
125*fb8edf90SEric Kohl return Status;
126*fb8edf90SEric Kohl
127c2c66affSColin Finck RtlInitializeResource(&SampResource);
128c2c66affSColin Finck
129c2c66affSColin Finck /* Initialize the SAM database */
130c2c66affSColin Finck Status = SampInitDatabase();
131c2c66affSColin Finck if (!NT_SUCCESS(Status))
132c2c66affSColin Finck return Status;
133c2c66affSColin Finck
134c2c66affSColin Finck /* Start the RPC server */
135c2c66affSColin Finck SampStartRpcServer();
136c2c66affSColin Finck
137c2c66affSColin Finck return Status;
138c2c66affSColin Finck }
139c2c66affSColin Finck
140c2c66affSColin Finck
141c2c66affSColin Finck NTSTATUS
142c2c66affSColin Finck NTAPI
SampInitializeRegistry(VOID)143c2c66affSColin Finck SampInitializeRegistry(VOID)
144c2c66affSColin Finck {
145c2c66affSColin Finck TRACE("SampInitializeRegistry() called\n");
146c2c66affSColin Finck
147c2c66affSColin Finck SampInitializeSAM();
148c2c66affSColin Finck
149c2c66affSColin Finck return STATUS_SUCCESS;
150c2c66affSColin Finck }
151c2c66affSColin Finck
152c2c66affSColin Finck
153c2c66affSColin Finck VOID
154c2c66affSColin Finck NTAPI
SamIFreeVoid(PVOID Ptr)155c2c66affSColin Finck SamIFreeVoid(PVOID Ptr)
156c2c66affSColin Finck {
157c2c66affSColin Finck MIDL_user_free(Ptr);
158c2c66affSColin Finck }
159c2c66affSColin Finck
160c2c66affSColin Finck
161c2c66affSColin Finck VOID
162c2c66affSColin Finck NTAPI
SamIFree_SAMPR_ALIAS_INFO_BUFFER(PSAMPR_ALIAS_INFO_BUFFER Ptr,ALIAS_INFORMATION_CLASS InformationClass)163c2c66affSColin Finck SamIFree_SAMPR_ALIAS_INFO_BUFFER(
164c2c66affSColin Finck PSAMPR_ALIAS_INFO_BUFFER Ptr,
165c2c66affSColin Finck ALIAS_INFORMATION_CLASS InformationClass)
166c2c66affSColin Finck {
167c2c66affSColin Finck if (Ptr == NULL)
168c2c66affSColin Finck return;
169c2c66affSColin Finck
170c2c66affSColin Finck switch (InformationClass)
171c2c66affSColin Finck {
172c2c66affSColin Finck case AliasGeneralInformation:
173c2c66affSColin Finck if (Ptr->General.Name.Buffer != NULL)
174c2c66affSColin Finck MIDL_user_free(Ptr->General.Name.Buffer);
175c2c66affSColin Finck
176c2c66affSColin Finck if (Ptr->General.AdminComment.Buffer != NULL)
177c2c66affSColin Finck MIDL_user_free(Ptr->General.AdminComment.Buffer);
178c2c66affSColin Finck break;
179c2c66affSColin Finck
180c2c66affSColin Finck case AliasNameInformation:
181c2c66affSColin Finck if (Ptr->Name.Name.Buffer != NULL)
182c2c66affSColin Finck MIDL_user_free(Ptr->Name.Name.Buffer);
183c2c66affSColin Finck break;
184c2c66affSColin Finck
185c2c66affSColin Finck case AliasAdminCommentInformation:
186c2c66affSColin Finck if (Ptr->AdminComment.AdminComment.Buffer != NULL)
187c2c66affSColin Finck MIDL_user_free(Ptr->AdminComment.AdminComment.Buffer);
188c2c66affSColin Finck break;
189c2c66affSColin Finck
190c2c66affSColin Finck default:
191c2c66affSColin Finck FIXME("Unsupported information class: %lu\n", InformationClass);
192c2c66affSColin Finck break;
193c2c66affSColin Finck }
194c2c66affSColin Finck
195c2c66affSColin Finck MIDL_user_free(Ptr);
196c2c66affSColin Finck }
197c2c66affSColin Finck
198c2c66affSColin Finck
199c2c66affSColin Finck VOID
200c2c66affSColin Finck NTAPI
SamIFree_SAMPR_DISPLAY_INFO_BUFFER(PSAMPR_DISPLAY_INFO_BUFFER Ptr,DOMAIN_DISPLAY_INFORMATION InformationClass)201c2c66affSColin Finck SamIFree_SAMPR_DISPLAY_INFO_BUFFER(
202c2c66affSColin Finck PSAMPR_DISPLAY_INFO_BUFFER Ptr,
203c2c66affSColin Finck DOMAIN_DISPLAY_INFORMATION InformationClass)
204c2c66affSColin Finck {
205c2c66affSColin Finck ULONG i;
206c2c66affSColin Finck
207c2c66affSColin Finck if (Ptr == NULL)
208c2c66affSColin Finck return;
209c2c66affSColin Finck
210c2c66affSColin Finck switch (InformationClass)
211c2c66affSColin Finck {
212c2c66affSColin Finck case DomainDisplayUser:
213c2c66affSColin Finck if (Ptr->UserInformation.Buffer != NULL)
214c2c66affSColin Finck {
215c2c66affSColin Finck for (i = 0; i < Ptr->UserInformation.EntriesRead; i++)
216c2c66affSColin Finck {
217c2c66affSColin Finck if (Ptr->UserInformation.Buffer[i].AccountName.Buffer != NULL)
218c2c66affSColin Finck MIDL_user_free(Ptr->UserInformation.Buffer[i].AccountName.Buffer);
219c2c66affSColin Finck
220c2c66affSColin Finck if (Ptr->UserInformation.Buffer[i].AdminComment.Buffer != NULL)
221c2c66affSColin Finck MIDL_user_free(Ptr->UserInformation.Buffer[i].AdminComment.Buffer);
222c2c66affSColin Finck
223c2c66affSColin Finck if (Ptr->UserInformation.Buffer[i].FullName.Buffer != NULL)
224c2c66affSColin Finck MIDL_user_free(Ptr->UserInformation.Buffer[i].FullName.Buffer);
225c2c66affSColin Finck }
226c2c66affSColin Finck
227c2c66affSColin Finck MIDL_user_free(Ptr->UserInformation.Buffer);
228c2c66affSColin Finck }
229c2c66affSColin Finck break;
230c2c66affSColin Finck
231c2c66affSColin Finck case DomainDisplayMachine:
232c2c66affSColin Finck if (Ptr->MachineInformation.Buffer != NULL)
233c2c66affSColin Finck {
234c2c66affSColin Finck for (i = 0; i < Ptr->MachineInformation.EntriesRead; i++)
235c2c66affSColin Finck {
236c2c66affSColin Finck if (Ptr->MachineInformation.Buffer[i].AccountName.Buffer != NULL)
237c2c66affSColin Finck MIDL_user_free(Ptr->MachineInformation.Buffer[i].AccountName.Buffer);
238c2c66affSColin Finck
239c2c66affSColin Finck if (Ptr->MachineInformation.Buffer[i].AdminComment.Buffer != NULL)
240c2c66affSColin Finck MIDL_user_free(Ptr->MachineInformation.Buffer[i].AdminComment.Buffer);
241c2c66affSColin Finck }
242c2c66affSColin Finck
243c2c66affSColin Finck MIDL_user_free(Ptr->MachineInformation.Buffer);
244c2c66affSColin Finck }
245c2c66affSColin Finck break;
246c2c66affSColin Finck
247c2c66affSColin Finck case DomainDisplayGroup:
248c2c66affSColin Finck if (Ptr->GroupInformation.Buffer != NULL)
249c2c66affSColin Finck {
250c2c66affSColin Finck for (i = 0; i < Ptr->GroupInformation.EntriesRead; i++)
251c2c66affSColin Finck {
252c2c66affSColin Finck if (Ptr->GroupInformation.Buffer[i].AccountName.Buffer != NULL)
253c2c66affSColin Finck MIDL_user_free(Ptr->GroupInformation.Buffer[i].AccountName.Buffer);
254c2c66affSColin Finck
255c2c66affSColin Finck if (Ptr->GroupInformation.Buffer[i].AdminComment.Buffer != NULL)
256c2c66affSColin Finck MIDL_user_free(Ptr->GroupInformation.Buffer[i].AdminComment.Buffer);
257c2c66affSColin Finck }
258c2c66affSColin Finck
259c2c66affSColin Finck MIDL_user_free(Ptr->GroupInformation.Buffer);
260c2c66affSColin Finck }
261c2c66affSColin Finck break;
262c2c66affSColin Finck
263c2c66affSColin Finck case DomainDisplayOemUser:
264c2c66affSColin Finck if (Ptr->OemUserInformation.Buffer != NULL)
265c2c66affSColin Finck {
266c2c66affSColin Finck for (i = 0; i < Ptr->OemUserInformation.EntriesRead; i++)
267c2c66affSColin Finck {
268c2c66affSColin Finck if (Ptr->OemUserInformation.Buffer[i].OemAccountName.Buffer != NULL)
269c2c66affSColin Finck MIDL_user_free(Ptr->OemUserInformation.Buffer[i].OemAccountName.Buffer);
270c2c66affSColin Finck }
271c2c66affSColin Finck
272c2c66affSColin Finck MIDL_user_free(Ptr->OemUserInformation.Buffer);
273c2c66affSColin Finck }
274c2c66affSColin Finck break;
275c2c66affSColin Finck
276c2c66affSColin Finck case DomainDisplayOemGroup:
277c2c66affSColin Finck if (Ptr->OemGroupInformation.Buffer != NULL)
278c2c66affSColin Finck {
279c2c66affSColin Finck for (i = 0; i < Ptr->OemGroupInformation.EntriesRead; i++)
280c2c66affSColin Finck {
281c2c66affSColin Finck if (Ptr->OemGroupInformation.Buffer[i].OemAccountName.Buffer != NULL)
282c2c66affSColin Finck MIDL_user_free(Ptr->OemGroupInformation.Buffer[i].OemAccountName.Buffer);
283c2c66affSColin Finck }
284c2c66affSColin Finck
285c2c66affSColin Finck MIDL_user_free(Ptr->OemGroupInformation.Buffer);
286c2c66affSColin Finck }
287c2c66affSColin Finck break;
288c2c66affSColin Finck
289c2c66affSColin Finck default:
290c2c66affSColin Finck FIXME("Unsupported information class: %lu\n", InformationClass);
291c2c66affSColin Finck break;
292c2c66affSColin Finck }
293c2c66affSColin Finck }
294c2c66affSColin Finck
295c2c66affSColin Finck
296c2c66affSColin Finck VOID
297c2c66affSColin Finck NTAPI
SamIFree_SAMPR_DOMAIN_INFO_BUFFER(PSAMPR_DOMAIN_INFO_BUFFER Ptr,DOMAIN_INFORMATION_CLASS InformationClass)298c2c66affSColin Finck SamIFree_SAMPR_DOMAIN_INFO_BUFFER(
299c2c66affSColin Finck PSAMPR_DOMAIN_INFO_BUFFER Ptr,
300c2c66affSColin Finck DOMAIN_INFORMATION_CLASS InformationClass)
301c2c66affSColin Finck {
302c2c66affSColin Finck if (Ptr == NULL)
303c2c66affSColin Finck return;
304c2c66affSColin Finck
305c2c66affSColin Finck switch (InformationClass)
306c2c66affSColin Finck {
307c2c66affSColin Finck case DomainPasswordInformation:
308c2c66affSColin Finck break;
309c2c66affSColin Finck
310c2c66affSColin Finck case DomainGeneralInformation:
311c2c66affSColin Finck if (Ptr->General.OemInformation.Buffer != NULL)
312c2c66affSColin Finck MIDL_user_free(Ptr->General.OemInformation.Buffer);
313c2c66affSColin Finck
314c2c66affSColin Finck if (Ptr->General.DomainName.Buffer != NULL)
315c2c66affSColin Finck MIDL_user_free(Ptr->General.DomainName.Buffer);
316c2c66affSColin Finck
317c2c66affSColin Finck if (Ptr->General.ReplicaSourceNodeName.Buffer != NULL)
318c2c66affSColin Finck MIDL_user_free(Ptr->General.ReplicaSourceNodeName.Buffer);
319c2c66affSColin Finck break;
320c2c66affSColin Finck
321c2c66affSColin Finck case DomainLogoffInformation:
322c2c66affSColin Finck break;
323c2c66affSColin Finck
324c2c66affSColin Finck case DomainOemInformation:
325c2c66affSColin Finck if (Ptr->Oem.OemInformation.Buffer != NULL)
326c2c66affSColin Finck MIDL_user_free(Ptr->Oem.OemInformation.Buffer);
327c2c66affSColin Finck break;
328c2c66affSColin Finck
329c2c66affSColin Finck case DomainNameInformation:
330c2c66affSColin Finck if (Ptr->Name.DomainName.Buffer != NULL)
331c2c66affSColin Finck MIDL_user_free(Ptr->Name.DomainName.Buffer);
332c2c66affSColin Finck break;
333c2c66affSColin Finck
334c2c66affSColin Finck case DomainReplicationInformation:
335c2c66affSColin Finck if (Ptr->Replication.ReplicaSourceNodeName.Buffer != NULL)
336c2c66affSColin Finck MIDL_user_free(Ptr->Replication.ReplicaSourceNodeName.Buffer);
337c2c66affSColin Finck break;
338c2c66affSColin Finck
339c2c66affSColin Finck case DomainServerRoleInformation:
340c2c66affSColin Finck break;
341c2c66affSColin Finck
342c2c66affSColin Finck case DomainModifiedInformation:
343c2c66affSColin Finck break;
344c2c66affSColin Finck
345c2c66affSColin Finck case DomainStateInformation:
346c2c66affSColin Finck break;
347c2c66affSColin Finck
348c2c66affSColin Finck case DomainGeneralInformation2:
349c2c66affSColin Finck if (Ptr->General2.I1.OemInformation.Buffer != NULL)
350c2c66affSColin Finck MIDL_user_free(Ptr->General2.I1.OemInformation.Buffer);
351c2c66affSColin Finck
352c2c66affSColin Finck if (Ptr->General2.I1.DomainName.Buffer != NULL)
353c2c66affSColin Finck MIDL_user_free(Ptr->General2.I1.DomainName.Buffer);
354c2c66affSColin Finck
355c2c66affSColin Finck if (Ptr->General2.I1.ReplicaSourceNodeName.Buffer != NULL)
356c2c66affSColin Finck MIDL_user_free(Ptr->General2.I1.ReplicaSourceNodeName.Buffer);
357c2c66affSColin Finck break;
358c2c66affSColin Finck
359c2c66affSColin Finck case DomainLockoutInformation:
360c2c66affSColin Finck break;
361c2c66affSColin Finck
362c2c66affSColin Finck case DomainModifiedInformation2:
363c2c66affSColin Finck break;
364c2c66affSColin Finck
365c2c66affSColin Finck default:
366c2c66affSColin Finck FIXME("Unsupported information class: %lu\n", InformationClass);
367c2c66affSColin Finck break;
368c2c66affSColin Finck }
369c2c66affSColin Finck
370c2c66affSColin Finck MIDL_user_free(Ptr);
371c2c66affSColin Finck }
372c2c66affSColin Finck
373c2c66affSColin Finck
374c2c66affSColin Finck VOID
375c2c66affSColin Finck NTAPI
SamIFree_SAMPR_ENUMERATION_BUFFER(PSAMPR_ENUMERATION_BUFFER Ptr)376c2c66affSColin Finck SamIFree_SAMPR_ENUMERATION_BUFFER(PSAMPR_ENUMERATION_BUFFER Ptr)
377c2c66affSColin Finck {
378c2c66affSColin Finck ULONG i;
379c2c66affSColin Finck
380c2c66affSColin Finck if (Ptr == NULL)
381c2c66affSColin Finck return;
382c2c66affSColin Finck
383c2c66affSColin Finck if (Ptr->Buffer != NULL)
384c2c66affSColin Finck {
385c2c66affSColin Finck for (i = 0; i < Ptr->EntriesRead; i++)
386c2c66affSColin Finck {
387c2c66affSColin Finck if (Ptr->Buffer[i].Name.Buffer != NULL)
388c2c66affSColin Finck MIDL_user_free(Ptr->Buffer[i].Name.Buffer);
389c2c66affSColin Finck }
390c2c66affSColin Finck
391c2c66affSColin Finck MIDL_user_free(Ptr->Buffer);
392c2c66affSColin Finck }
393c2c66affSColin Finck
394c2c66affSColin Finck MIDL_user_free(Ptr);
395c2c66affSColin Finck }
396c2c66affSColin Finck
397c2c66affSColin Finck
398c2c66affSColin Finck VOID
399c2c66affSColin Finck NTAPI
SamIFree_SAMPR_GET_GROUPS_BUFFER(PSAMPR_GET_GROUPS_BUFFER Ptr)400c2c66affSColin Finck SamIFree_SAMPR_GET_GROUPS_BUFFER(PSAMPR_GET_GROUPS_BUFFER Ptr)
401c2c66affSColin Finck {
402c2c66affSColin Finck if (Ptr == NULL)
403c2c66affSColin Finck return;
404c2c66affSColin Finck
405c2c66affSColin Finck if (Ptr->Groups != NULL)
406c2c66affSColin Finck MIDL_user_free(Ptr->Groups);
407c2c66affSColin Finck
408c2c66affSColin Finck MIDL_user_free(Ptr);
409c2c66affSColin Finck }
410c2c66affSColin Finck
411c2c66affSColin Finck
412c2c66affSColin Finck VOID
413c2c66affSColin Finck NTAPI
SamIFree_SAMPR_GET_MEMBERS_BUFFER(PSAMPR_GET_MEMBERS_BUFFER Ptr)414c2c66affSColin Finck SamIFree_SAMPR_GET_MEMBERS_BUFFER(PSAMPR_GET_MEMBERS_BUFFER Ptr)
415c2c66affSColin Finck {
416c2c66affSColin Finck if (Ptr == NULL)
417c2c66affSColin Finck return;
418c2c66affSColin Finck
419c2c66affSColin Finck if (Ptr->Members != NULL)
420c2c66affSColin Finck MIDL_user_free(Ptr->Members);
421c2c66affSColin Finck
422c2c66affSColin Finck if (Ptr->Attributes != NULL)
423c2c66affSColin Finck MIDL_user_free(Ptr->Attributes);
424c2c66affSColin Finck
425c2c66affSColin Finck MIDL_user_free(Ptr);
426c2c66affSColin Finck }
427c2c66affSColin Finck
428c2c66affSColin Finck
429c2c66affSColin Finck VOID
430c2c66affSColin Finck NTAPI
SamIFree_SAMPR_GROUP_INFO_BUFFER(PSAMPR_GROUP_INFO_BUFFER Ptr,GROUP_INFORMATION_CLASS InformationClass)431c2c66affSColin Finck SamIFree_SAMPR_GROUP_INFO_BUFFER(
432c2c66affSColin Finck PSAMPR_GROUP_INFO_BUFFER Ptr,
433c2c66affSColin Finck GROUP_INFORMATION_CLASS InformationClass)
434c2c66affSColin Finck {
435c2c66affSColin Finck if (Ptr == NULL)
436c2c66affSColin Finck return;
437c2c66affSColin Finck
438c2c66affSColin Finck switch (InformationClass)
439c2c66affSColin Finck {
440c2c66affSColin Finck case GroupGeneralInformation:
441c2c66affSColin Finck if (Ptr->General.Name.Buffer != NULL)
442c2c66affSColin Finck MIDL_user_free(Ptr->General.Name.Buffer);
443c2c66affSColin Finck
444c2c66affSColin Finck if (Ptr->General.AdminComment.Buffer != NULL)
445c2c66affSColin Finck MIDL_user_free(Ptr->General.AdminComment.Buffer);
446c2c66affSColin Finck break;
447c2c66affSColin Finck
448c2c66affSColin Finck case GroupNameInformation:
449c2c66affSColin Finck if (Ptr->Name.Name.Buffer != NULL)
450c2c66affSColin Finck MIDL_user_free(Ptr->Name.Name.Buffer);
451c2c66affSColin Finck break;
452c2c66affSColin Finck
453c2c66affSColin Finck case GroupAttributeInformation:
454c2c66affSColin Finck break;
455c2c66affSColin Finck
456c2c66affSColin Finck case GroupAdminCommentInformation:
457c2c66affSColin Finck if (Ptr->AdminComment.AdminComment.Buffer != NULL)
458c2c66affSColin Finck MIDL_user_free(Ptr->AdminComment.AdminComment.Buffer);
459c2c66affSColin Finck break;
460c2c66affSColin Finck
461c2c66affSColin Finck default:
462c2c66affSColin Finck FIXME("Unsupported information class: %lu\n", InformationClass);
463c2c66affSColin Finck break;
464c2c66affSColin Finck }
465c2c66affSColin Finck
466c2c66affSColin Finck MIDL_user_free(Ptr);
467c2c66affSColin Finck }
468c2c66affSColin Finck
469c2c66affSColin Finck
470c2c66affSColin Finck VOID
471c2c66affSColin Finck NTAPI
SamIFree_SAMPR_PSID_ARRAY(PSAMPR_PSID_ARRAY Ptr)472c2c66affSColin Finck SamIFree_SAMPR_PSID_ARRAY(PSAMPR_PSID_ARRAY Ptr)
473c2c66affSColin Finck {
474c2c66affSColin Finck if (Ptr == NULL)
475c2c66affSColin Finck return;
476c2c66affSColin Finck
477c2c66affSColin Finck if (Ptr->Sids != NULL)
478c2c66affSColin Finck {
479c2c66affSColin Finck MIDL_user_free(Ptr->Sids);
480c2c66affSColin Finck }
481c2c66affSColin Finck }
482c2c66affSColin Finck
483c2c66affSColin Finck
484c2c66affSColin Finck VOID
485c2c66affSColin Finck NTAPI
SamIFree_SAMPR_RETURNED_USTRING_ARRAY(PSAMPR_RETURNED_USTRING_ARRAY Ptr)486c2c66affSColin Finck SamIFree_SAMPR_RETURNED_USTRING_ARRAY(PSAMPR_RETURNED_USTRING_ARRAY Ptr)
487c2c66affSColin Finck {
488c2c66affSColin Finck ULONG i;
489c2c66affSColin Finck
490c2c66affSColin Finck if (Ptr == NULL)
491c2c66affSColin Finck return;
492c2c66affSColin Finck
493c2c66affSColin Finck if (Ptr->Element != NULL)
494c2c66affSColin Finck {
495c2c66affSColin Finck for (i = 0; i < Ptr->Count; i++)
496c2c66affSColin Finck {
497c2c66affSColin Finck if (Ptr->Element[i].Buffer != NULL)
498c2c66affSColin Finck MIDL_user_free(Ptr->Element[i].Buffer);
499c2c66affSColin Finck }
500c2c66affSColin Finck
501c2c66affSColin Finck MIDL_user_free(Ptr->Element);
502c2c66affSColin Finck Ptr->Element = NULL;
503c2c66affSColin Finck Ptr->Count = 0;
504c2c66affSColin Finck }
505c2c66affSColin Finck }
506c2c66affSColin Finck
507c2c66affSColin Finck
508c2c66affSColin Finck VOID
509c2c66affSColin Finck NTAPI
SamIFree_SAMPR_SR_SECURITY_DESCRIPTOR(PSAMPR_SR_SECURITY_DESCRIPTOR Ptr)510c2c66affSColin Finck SamIFree_SAMPR_SR_SECURITY_DESCRIPTOR(PSAMPR_SR_SECURITY_DESCRIPTOR Ptr)
511c2c66affSColin Finck {
512c2c66affSColin Finck if (Ptr == NULL)
513c2c66affSColin Finck return;
514c2c66affSColin Finck
515c2c66affSColin Finck if (Ptr->SecurityDescriptor != NULL)
516c2c66affSColin Finck MIDL_user_free(Ptr->SecurityDescriptor);
517c2c66affSColin Finck
518c2c66affSColin Finck MIDL_user_free(Ptr);
519c2c66affSColin Finck }
520c2c66affSColin Finck
521c2c66affSColin Finck
522c2c66affSColin Finck VOID
523c2c66affSColin Finck NTAPI
SamIFree_SAMPR_ULONG_ARRAY(PSAMPR_ULONG_ARRAY Ptr)524c2c66affSColin Finck SamIFree_SAMPR_ULONG_ARRAY(PSAMPR_ULONG_ARRAY Ptr)
525c2c66affSColin Finck {
526c2c66affSColin Finck if (Ptr == NULL)
527c2c66affSColin Finck return;
528c2c66affSColin Finck
529c2c66affSColin Finck if (Ptr->Element != NULL)
530c2c66affSColin Finck {
531c2c66affSColin Finck MIDL_user_free(Ptr->Element);
532c2c66affSColin Finck Ptr->Element = NULL;
533c2c66affSColin Finck Ptr->Count = 0;
534c2c66affSColin Finck }
535c2c66affSColin Finck }
536c2c66affSColin Finck
537c2c66affSColin Finck
538c2c66affSColin Finck VOID
539c2c66affSColin Finck NTAPI
SamIFree_SAMPR_USER_INFO_BUFFER(PSAMPR_USER_INFO_BUFFER Ptr,USER_INFORMATION_CLASS InformationClass)540c2c66affSColin Finck SamIFree_SAMPR_USER_INFO_BUFFER(PSAMPR_USER_INFO_BUFFER Ptr,
541c2c66affSColin Finck USER_INFORMATION_CLASS InformationClass)
542c2c66affSColin Finck {
543c2c66affSColin Finck if (Ptr == NULL)
544c2c66affSColin Finck return;
545c2c66affSColin Finck
546c2c66affSColin Finck switch (InformationClass)
547c2c66affSColin Finck {
548c2c66affSColin Finck case UserGeneralInformation:
549c2c66affSColin Finck if (Ptr->General.UserName.Buffer != NULL)
550c2c66affSColin Finck MIDL_user_free(Ptr->General.UserName.Buffer);
551c2c66affSColin Finck
552c2c66affSColin Finck if (Ptr->General.FullName.Buffer != NULL)
553c2c66affSColin Finck MIDL_user_free(Ptr->General.FullName.Buffer);
554c2c66affSColin Finck
555c2c66affSColin Finck if (Ptr->General.AdminComment.Buffer != NULL)
556c2c66affSColin Finck MIDL_user_free(Ptr->General.AdminComment.Buffer);
557c2c66affSColin Finck
558c2c66affSColin Finck if (Ptr->General.UserComment.Buffer != NULL)
559c2c66affSColin Finck MIDL_user_free(Ptr->General.UserComment.Buffer);
560c2c66affSColin Finck break;
561c2c66affSColin Finck
562c2c66affSColin Finck case UserPreferencesInformation:
563c2c66affSColin Finck if (Ptr->Preferences.UserComment.Buffer != NULL)
564c2c66affSColin Finck MIDL_user_free(Ptr->Preferences.UserComment.Buffer);
565c2c66affSColin Finck
566c2c66affSColin Finck if (Ptr->Preferences.Reserved1.Buffer != NULL)
567c2c66affSColin Finck MIDL_user_free(Ptr->Preferences.Reserved1.Buffer);
568c2c66affSColin Finck break;
569c2c66affSColin Finck
570c2c66affSColin Finck case UserLogonInformation:
571c2c66affSColin Finck if (Ptr->Logon.UserName.Buffer != NULL)
572c2c66affSColin Finck MIDL_user_free(Ptr->Logon.UserName.Buffer);
573c2c66affSColin Finck
574c2c66affSColin Finck if (Ptr->Logon.FullName.Buffer != NULL)
575c2c66affSColin Finck MIDL_user_free(Ptr->Logon.FullName.Buffer);
576c2c66affSColin Finck
577c2c66affSColin Finck if (Ptr->Logon.HomeDirectory.Buffer != NULL)
578c2c66affSColin Finck MIDL_user_free(Ptr->Logon.HomeDirectory.Buffer);
579c2c66affSColin Finck
580c2c66affSColin Finck if (Ptr->Logon.HomeDirectoryDrive.Buffer != NULL)
581c2c66affSColin Finck MIDL_user_free(Ptr->Logon.HomeDirectoryDrive.Buffer);
582c2c66affSColin Finck
583c2c66affSColin Finck if (Ptr->Logon.ScriptPath.Buffer != NULL)
584c2c66affSColin Finck MIDL_user_free(Ptr->Logon.ScriptPath.Buffer);
585c2c66affSColin Finck
586c2c66affSColin Finck if (Ptr->Logon.ProfilePath.Buffer != NULL)
587c2c66affSColin Finck MIDL_user_free(Ptr->Logon.ProfilePath.Buffer);
588c2c66affSColin Finck
589c2c66affSColin Finck if (Ptr->Logon.WorkStations.Buffer != NULL)
590c2c66affSColin Finck MIDL_user_free(Ptr->Logon.WorkStations.Buffer);
591c2c66affSColin Finck
592c2c66affSColin Finck if (Ptr->Logon.LogonHours.LogonHours != NULL)
593c2c66affSColin Finck MIDL_user_free(Ptr->Logon.LogonHours.LogonHours);
594c2c66affSColin Finck break;
595c2c66affSColin Finck
596c2c66affSColin Finck case UserLogonHoursInformation:
597c2c66affSColin Finck if (Ptr->LogonHours.LogonHours.LogonHours != NULL)
598c2c66affSColin Finck MIDL_user_free(Ptr->LogonHours.LogonHours.LogonHours);
599c2c66affSColin Finck break;
600c2c66affSColin Finck
601c2c66affSColin Finck case UserAccountInformation:
602c2c66affSColin Finck if (Ptr->Account.UserName.Buffer != NULL)
603c2c66affSColin Finck MIDL_user_free(Ptr->Account.UserName.Buffer);
604c2c66affSColin Finck
605c2c66affSColin Finck if (Ptr->Account.FullName.Buffer != NULL)
606c2c66affSColin Finck MIDL_user_free(Ptr->Account.FullName.Buffer);
607c2c66affSColin Finck
608c2c66affSColin Finck if (Ptr->Account.HomeDirectory.Buffer != NULL)
609c2c66affSColin Finck MIDL_user_free(Ptr->Account.HomeDirectory.Buffer);
610c2c66affSColin Finck
611c2c66affSColin Finck if (Ptr->Account.HomeDirectoryDrive.Buffer != NULL)
612c2c66affSColin Finck MIDL_user_free(Ptr->Account.HomeDirectoryDrive.Buffer);
613c2c66affSColin Finck
614c2c66affSColin Finck if (Ptr->Account.ScriptPath.Buffer != NULL)
615c2c66affSColin Finck MIDL_user_free(Ptr->Account.ScriptPath.Buffer);
616c2c66affSColin Finck
617c2c66affSColin Finck if (Ptr->Account.ProfilePath.Buffer != NULL)
618c2c66affSColin Finck MIDL_user_free(Ptr->Account.ProfilePath.Buffer);
619c2c66affSColin Finck
620c2c66affSColin Finck if (Ptr->Account.AdminComment.Buffer != NULL)
621c2c66affSColin Finck MIDL_user_free(Ptr->Account.AdminComment.Buffer);
622c2c66affSColin Finck
623c2c66affSColin Finck if (Ptr->Account.WorkStations.Buffer != NULL)
624c2c66affSColin Finck MIDL_user_free(Ptr->Account.WorkStations.Buffer);
625c2c66affSColin Finck
626c2c66affSColin Finck if (Ptr->Account.LogonHours.LogonHours != NULL)
627c2c66affSColin Finck MIDL_user_free(Ptr->Account.LogonHours.LogonHours);
628c2c66affSColin Finck break;
629c2c66affSColin Finck
630c2c66affSColin Finck case UserNameInformation:
631c2c66affSColin Finck if (Ptr->Name.UserName.Buffer != NULL)
632c2c66affSColin Finck MIDL_user_free(Ptr->Name.UserName.Buffer);
633c2c66affSColin Finck
634c2c66affSColin Finck if (Ptr->Name.FullName.Buffer != NULL)
635c2c66affSColin Finck MIDL_user_free(Ptr->Name.FullName.Buffer);
636c2c66affSColin Finck break;
637c2c66affSColin Finck
638c2c66affSColin Finck case UserAccountNameInformation:
639c2c66affSColin Finck if (Ptr->AccountName.UserName.Buffer != NULL)
640c2c66affSColin Finck MIDL_user_free(Ptr->AccountName.UserName.Buffer);
641c2c66affSColin Finck break;
642c2c66affSColin Finck
643c2c66affSColin Finck case UserFullNameInformation:
644c2c66affSColin Finck if (Ptr->FullName.FullName.Buffer != NULL)
645c2c66affSColin Finck MIDL_user_free(Ptr->FullName.FullName.Buffer);
646c2c66affSColin Finck break;
647c2c66affSColin Finck
648c2c66affSColin Finck case UserPrimaryGroupInformation:
649c2c66affSColin Finck break;
650c2c66affSColin Finck
651c2c66affSColin Finck case UserHomeInformation:
652c2c66affSColin Finck if (Ptr->Home.HomeDirectory.Buffer != NULL)
653c2c66affSColin Finck MIDL_user_free(Ptr->Home.HomeDirectory.Buffer);
654c2c66affSColin Finck
655c2c66affSColin Finck if (Ptr->Home.HomeDirectoryDrive.Buffer != NULL)
656c2c66affSColin Finck MIDL_user_free(Ptr->Home.HomeDirectoryDrive.Buffer);
657c2c66affSColin Finck break;
658c2c66affSColin Finck
659c2c66affSColin Finck case UserScriptInformation:
660c2c66affSColin Finck if (Ptr->Script.ScriptPath.Buffer != NULL)
661c2c66affSColin Finck MIDL_user_free(Ptr->Script.ScriptPath.Buffer);
662b59bad8dSSerge Gautherie break;
663c2c66affSColin Finck
664c2c66affSColin Finck case UserProfileInformation:
665c2c66affSColin Finck if (Ptr->Profile.ProfilePath.Buffer != NULL)
666c2c66affSColin Finck MIDL_user_free(Ptr->Profile.ProfilePath.Buffer);
667b59bad8dSSerge Gautherie break;
668c2c66affSColin Finck
669c2c66affSColin Finck case UserAdminCommentInformation:
670c2c66affSColin Finck if (Ptr->AdminComment.AdminComment.Buffer != NULL)
671c2c66affSColin Finck MIDL_user_free(Ptr->AdminComment.AdminComment.Buffer);
672c2c66affSColin Finck break;
673c2c66affSColin Finck
674c2c66affSColin Finck case UserWorkStationsInformation:
675c2c66affSColin Finck if (Ptr->WorkStations.WorkStations.Buffer != NULL)
676c2c66affSColin Finck MIDL_user_free(Ptr->WorkStations.WorkStations.Buffer);
677c2c66affSColin Finck break;
678c2c66affSColin Finck
679c2c66affSColin Finck case UserSetPasswordInformation:
680c2c66affSColin Finck ERR("Information class UserSetPasswordInformation cannot be queried!\n");
681c2c66affSColin Finck break;
682c2c66affSColin Finck
683c2c66affSColin Finck case UserControlInformation:
684c2c66affSColin Finck break;
685c2c66affSColin Finck
686c2c66affSColin Finck case UserExpiresInformation:
687c2c66affSColin Finck break;
688c2c66affSColin Finck
689c2c66affSColin Finck case UserInternal1Information:
690c2c66affSColin Finck break;
691c2c66affSColin Finck
692c2c66affSColin Finck case UserInternal2Information:
693c2c66affSColin Finck break;
694c2c66affSColin Finck
695c2c66affSColin Finck case UserParametersInformation:
696c2c66affSColin Finck if (Ptr->Parameters.Parameters.Buffer != NULL)
697c2c66affSColin Finck MIDL_user_free(Ptr->Parameters.Parameters.Buffer);
698c2c66affSColin Finck break;
699c2c66affSColin Finck
700c2c66affSColin Finck case UserAllInformation:
701c2c66affSColin Finck if (Ptr->All.UserName.Buffer != NULL)
702c2c66affSColin Finck MIDL_user_free(Ptr->All.UserName.Buffer);
703c2c66affSColin Finck
704c2c66affSColin Finck if (Ptr->All.FullName.Buffer != NULL)
705c2c66affSColin Finck MIDL_user_free(Ptr->All.FullName.Buffer);
706c2c66affSColin Finck
707c2c66affSColin Finck if (Ptr->All.HomeDirectory.Buffer != NULL)
708c2c66affSColin Finck MIDL_user_free(Ptr->All.HomeDirectory.Buffer);
709c2c66affSColin Finck
710c2c66affSColin Finck if (Ptr->All.HomeDirectoryDrive.Buffer != NULL)
711c2c66affSColin Finck MIDL_user_free(Ptr->All.HomeDirectoryDrive.Buffer);
712c2c66affSColin Finck
713c2c66affSColin Finck if (Ptr->All.ScriptPath.Buffer != NULL)
714c2c66affSColin Finck MIDL_user_free(Ptr->All.ScriptPath.Buffer);
715c2c66affSColin Finck
716c2c66affSColin Finck if (Ptr->All.ProfilePath.Buffer != NULL)
717c2c66affSColin Finck MIDL_user_free(Ptr->All.ProfilePath.Buffer);
718c2c66affSColin Finck
719c2c66affSColin Finck if (Ptr->All.AdminComment.Buffer != NULL)
720c2c66affSColin Finck MIDL_user_free(Ptr->All.AdminComment.Buffer);
721c2c66affSColin Finck
722c2c66affSColin Finck if (Ptr->All.WorkStations.Buffer != NULL)
723c2c66affSColin Finck MIDL_user_free(Ptr->All.WorkStations.Buffer);
724c2c66affSColin Finck
725c2c66affSColin Finck if (Ptr->All.UserComment.Buffer != NULL)
726c2c66affSColin Finck MIDL_user_free(Ptr->All.UserComment.Buffer);
727c2c66affSColin Finck
728c2c66affSColin Finck if (Ptr->All.Parameters.Buffer != NULL)
729c2c66affSColin Finck MIDL_user_free(Ptr->All.Parameters.Buffer);
730c2c66affSColin Finck
731c2c66affSColin Finck if (Ptr->All.LmOwfPassword.Buffer != NULL)
732c2c66affSColin Finck MIDL_user_free(Ptr->All.LmOwfPassword.Buffer);
733c2c66affSColin Finck
734c2c66affSColin Finck if (Ptr->All.NtOwfPassword.Buffer != NULL)
735c2c66affSColin Finck MIDL_user_free(Ptr->All.NtOwfPassword.Buffer);
736c2c66affSColin Finck
737c2c66affSColin Finck if (Ptr->All.PrivateData.Buffer != NULL)
738c2c66affSColin Finck MIDL_user_free(Ptr->All.PrivateData.Buffer);
739c2c66affSColin Finck
740c2c66affSColin Finck if (Ptr->All.SecurityDescriptor.SecurityDescriptor != NULL)
741c2c66affSColin Finck MIDL_user_free(Ptr->All.SecurityDescriptor.SecurityDescriptor);
742c2c66affSColin Finck
743c2c66affSColin Finck if (Ptr->All.LogonHours.LogonHours != NULL)
744c2c66affSColin Finck MIDL_user_free(Ptr->All.LogonHours.LogonHours);
745c2c66affSColin Finck break;
746c2c66affSColin Finck
747c2c66affSColin Finck default:
748c2c66affSColin Finck FIXME("Unsupported information class: %lu\n", InformationClass);
749c2c66affSColin Finck break;
750c2c66affSColin Finck }
751c2c66affSColin Finck
752c2c66affSColin Finck MIDL_user_free(Ptr);
753c2c66affSColin Finck }
754c2c66affSColin Finck
755c2c66affSColin Finck /* EOF */
756