ReactOS 0.4.15-dev-8231-g29a56f3
clictx.c
Go to the documentation of this file.
1/*
2 * ReactOS Authorization Framework
3 * Copyright (C) 2005 - 2006 ReactOS Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19/*
20 * PROJECT: ReactOS Authorization Framework
21 * FILE: lib/authz/clictx.c
22 * PURPOSE: Authorization Framework
23 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
24 *
25 * UPDATE HISTORY:
26 * 10/07/2005 Created
27 */
28
29#include "precomp.h"
30
31#define NDEBUG
32#include <debug.h>
33
34/*
35 * @unimplemented
36 */
38BOOL
41 IN PSID UserSid,
42 IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager,
43 IN PLARGE_INTEGER pExpirationTime,
45 IN PVOID DynamicGroupArgs,
46 OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext)
47{
48 BOOL Ret = FALSE;
49
50 if (AuthzResourceManager != NULL && pExpirationTime != NULL && pAuthzClientContext != NULL &&
51 UserSid != NULL && IsValidSid(UserSid) && !(Flags & (AUTHZ_SKIP_TOKEN_GROUPS | AUTHZ_REQUIRE_S4U_LOGON)))
52 {
53 PAUTHZ_CLIENT_CONTEXT ClientCtx;
54 //PAUTHZ_RESMAN ResMan = (PAUTHZ_RESMAN)AuthzResourceManager;
55
56 VALIDATE_RESMAN_HANDLE(AuthzResourceManager);
57
59 sizeof(AUTHZ_CLIENT_CONTEXT));
60 if (ClientCtx != NULL)
61 {
62 DWORD SidLen;
63
64 /* initialize the client context structure */
65#if DBG
66 ClientCtx->Tag = CLIENTCTX_TAG;
67#endif
68
69 /* simply copy the SID */
70 SidLen = GetLengthSid(UserSid);
71 ClientCtx->UserSid = (PSID)LocalAlloc(LMEM_FIXED,
72 SidLen);
73 if (ClientCtx->UserSid == NULL)
74 {
75 LocalFree((HLOCAL)ClientCtx);
76 goto FailNoMemory;
77 }
78 CopySid(SidLen,
79 ClientCtx->UserSid,
80 UserSid);
81
82 ClientCtx->AuthzResourceManager = AuthzResourceManager;
83 ClientCtx->Luid = Identifier;
84 ClientCtx->ExpirationTime.QuadPart = (pExpirationTime != NULL ? pExpirationTime->QuadPart : 0);
85 ClientCtx->ServerContext = NULL; /* FIXME */
86 ClientCtx->DynamicGroupArgs = DynamicGroupArgs;
87
88 /* return the client context handle */
89 *pAuthzClientContext = (AUTHZ_CLIENT_CONTEXT_HANDLE)ClientCtx;
90 Ret = TRUE;
91 }
92 else
93 {
94FailNoMemory:
96 }
97 }
98 else
100
101 return Ret;
102}
103
104
105/*
106 * @unimplemented
107 */
109BOOL
110WINAPI
114 OUT PDWORD pSizeRequired,
116{
117 BOOL Ret = FALSE;
118
119 if (hAuthzClientContext != NULL && pSizeRequired != NULL)
120 {
121 PAUTHZ_CLIENT_CONTEXT ClientCtx = (PAUTHZ_CLIENT_CONTEXT)hAuthzClientContext;
122
123 VALIDATE_CLIENTCTX_HANDLE(hAuthzClientContext);
124
125 switch (InfoClass)
126 {
128 {
129 DWORD SidLen = GetLengthSid(ClientCtx->UserSid);
130 *pSizeRequired = SidLen;
131 if (BufferSize < SidLen)
132 {
134 }
135 else
136 {
137 Ret = CopySid(SidLen,
138 (PSID)Buffer,
139 ClientCtx->UserSid);
140 }
141 break;
142 }
143
146 break;
147
150 break;
151
154 break;
155
157 *pSizeRequired = sizeof(LARGE_INTEGER);
158 if (BufferSize < sizeof(LARGE_INTEGER) || Buffer == NULL)
159 {
161 }
162 else
163 {
164 *((PLARGE_INTEGER)Buffer) = ClientCtx->ExpirationTime;
165 Ret = TRUE;
166 }
167 break;
168
170 *pSizeRequired = sizeof(AUTHZ_CLIENT_CONTEXT_HANDLE);
172 {
174 }
175 else
176 {
178 Ret = TRUE;
179 }
180 break;
181
183 *pSizeRequired = sizeof(LUID);
184 if (BufferSize < sizeof(LUID) || Buffer == NULL)
185 {
187 }
188 else
189 {
190 *((PLUID)Buffer) = ClientCtx->Luid;
191 Ret = TRUE;
192 }
193 break;
194
195 default:
197 break;
198 }
199 }
200 else
202
203 return Ret;
204}
205
206
207/*
208 * @implemented
209 */
211BOOL
212WINAPI
214{
215 BOOL Ret = FALSE;
216
217 if (AuthzClientContext != NULL)
218 {
219 PAUTHZ_CLIENT_CONTEXT ClientCtx = (PAUTHZ_CLIENT_CONTEXT)AuthzClientContext;
220
221 VALIDATE_CLIENTCTX_HANDLE(AuthzClientContext);
222
223 if (ClientCtx->UserSid != NULL)
224 {
225 LocalFree((HLOCAL)ClientCtx->UserSid);
226 }
227
228 LocalFree((HLOCAL)ClientCtx);
229 Ret = TRUE;
230 }
231 else
233
234 return Ret;
235}
@ Identifier
Definition: asmpp.cpp:95
HANDLE * PAUTHZ_CLIENT_CONTEXT_HANDLE
Definition: authz.h:45
@ AuthzContextInfoGroupsSids
Definition: authz.h:61
@ AuthzContextInfoPrivileges
Definition: authz.h:63
@ AuthzContextInfoRestrictedSids
Definition: authz.h:62
@ AuthzContextInfoUserSid
Definition: authz.h:60
@ AuthzContextInfoExpirationTime
Definition: authz.h:64
@ AuthzContextInfoServerContext
Definition: authz.h:65
@ AuthzContextInfoIdentifier
Definition: authz.h:66
#define AUTHZ_REQUIRE_S4U_LOGON
Definition: authz.h:36
HANDLE AUTHZ_CLIENT_CONTEXT_HANDLE
Definition: authz.h:45
#define AUTHZAPI
Definition: authz.h:21
#define AUTHZ_SKIP_TOKEN_GROUPS
Definition: authz.h:35
enum _AUTHZ_CONTEXT_INFORMATION_CLASS AUTHZ_CONTEXT_INFORMATION_CLASS
Definition: bufpool.h:45
AUTHZAPI BOOL WINAPI AuthzInitializeContextFromSid(IN DWORD Flags, IN PSID UserSid, IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager, IN PLARGE_INTEGER pExpirationTime, IN LUID Identifier, IN PVOID DynamicGroupArgs, OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext)
Definition: clictx.c:40
AUTHZAPI BOOL WINAPI AuthzFreeContext(IN AUTHZ_CLIENT_CONTEXT_HANDLE AuthzClientContext)
Definition: clictx.c:213
AUTHZAPI BOOL WINAPI AuthzGetInformationFromContext(IN AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext, IN AUTHZ_CONTEXT_INFORMATION_CLASS InfoClass, IN DWORD BufferSize, OUT PDWORD pSizeRequired, OUT PVOID Buffer)
Definition: clictx.c:111
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
struct _LUID * PLUID
struct _LUID LUID
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI IsValidSid(PSID pSid)
Definition: security.c:819
BOOL WINAPI CopySid(DWORD nDestinationSidLength, PSID pDestinationSid, PSID pSourceSid)
Definition: security.c:712
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
#define VALIDATE_CLIENTCTX_HANDLE(handle)
Definition: precomp.h:27
#define VALIDATE_RESMAN_HANDLE(handle)
Definition: precomp.h:26
struct _AUTHZ_CLIENT_CONTEXT * PAUTHZ_CLIENT_CONTEXT
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
struct _SID * PSID
Definition: eventlog.c:35
DWORD * PDWORD
Definition: pedump.c:68
AUTHZ_CLIENT_CONTEXT_HANDLE ServerContext
Definition: precomp.h:59
PVOID DynamicGroupArgs
Definition: precomp.h:60
LARGE_INTEGER ExpirationTime
Definition: precomp.h:58
AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager
Definition: precomp.h:56
union _LARGE_INTEGER LARGE_INTEGER
#define IN
Definition: typedefs.h:39
union _LARGE_INTEGER * PLARGE_INTEGER
Definition: file.c:85
#define OUT
Definition: typedefs.h:40
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define LMEM_FIXED
Definition: winbase.h:368
#define WINAPI
Definition: msvc.h:6
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170