3 * Copyright (C) 2005 Eric Kohl
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 /* INCLUDES *****************************************************************/
24 WINE_DEFAULT_DEBUG_CHANNEL(samsrv
);
26 /* FUNCTIONS ****************************************************************/
30 SamIConnect(IN PSAMPR_SERVER_NAME ServerName
,
31 OUT SAMPR_HANDLE
*ServerHandle
,
32 IN ACCESS_MASK DesiredAccess
,
35 PSAM_DB_OBJECT ServerObject
;
38 TRACE("SamIConnect(%p %p %lx %ld)\n",
39 ServerName
, ServerHandle
, DesiredAccess
, Trusted
);
41 /* Map generic access rights */
42 RtlMapGenericMask(&DesiredAccess
,
45 /* Open the Server Object */
46 Status
= SampOpenDbObject(NULL
,
53 if (NT_SUCCESS(Status
))
55 ServerObject
->Trusted
= Trusted
;
56 *ServerHandle
= (SAMPR_HANDLE
)ServerObject
;
59 TRACE("SamIConnect done (Status 0x%08lx)\n", Status
);
69 NTSTATUS Status
= STATUS_SUCCESS
;
71 TRACE("SamIInitialize() called\n");
73 if (SampIsSetupRunning())
75 Status
= SampInitializeRegistry();
76 if (!NT_SUCCESS(Status
))
80 /* Initialize the SAM database */
81 Status
= SampInitDatabase();
82 if (!NT_SUCCESS(Status
))
85 /* Start the RPC server */
94 SampInitializeRegistry(VOID
)
96 TRACE("SampInitializeRegistry() called\n");
100 return STATUS_SUCCESS
;
106 SamIFree_SAMPR_ENUMERATION_BUFFER(PSAMPR_ENUMERATION_BUFFER Ptr
)
112 if (Ptr
->Buffer
!= NULL
)
114 for (i
= 0; i
< Ptr
->EntriesRead
; i
++)
116 if (Ptr
->Buffer
[i
].Name
.Buffer
!= NULL
)
117 MIDL_user_free(Ptr
->Buffer
[i
].Name
.Buffer
);
120 MIDL_user_free(Ptr
->Buffer
);
130 SamIFree_SAMPR_PSID_ARRAY(PSAMPR_PSID_ARRAY Ptr
)
136 MIDL_user_free(Ptr
->Sids
);
144 SamIFree_SAMPR_RETURNED_USTRING_ARRAY(PSAMPR_RETURNED_USTRING_ARRAY Ptr
)
150 if (Ptr
->Element
!= NULL
)
152 for (i
= 0; i
< Ptr
->Count
; i
++)
154 if (Ptr
->Element
[i
].Buffer
!= NULL
)
155 MIDL_user_free(Ptr
->Element
[i
].Buffer
);
158 MIDL_user_free(Ptr
->Element
);
168 SamIFree_SAMPR_ULONG_ARRAY(PSAMPR_ULONG_ARRAY Ptr
)
172 if (Ptr
->Element
!= NULL
)
174 MIDL_user_free(Ptr
->Element
);