1 /* $Id: security.c,v 1.4 2001/11/21 22:30:45 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/ntdll/rtl/security.c
6 * PURPOSE: Miscellaneous securitiy related functions
7 * PROGRAMMER: Eric Kohl
12 #include <ddk/ntddk.h>
13 #include <ntdll/rtl.h>
17 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
)
19 OBJECT_ATTRIBUTES ObjectAttributes
;
20 SECURITY_QUALITY_OF_SERVICE SecQos
;
22 HANDLE ImpersonationToken
;
25 Status
= NtOpenProcessToken(NtCurrentProcess(),
28 if (!NT_SUCCESS(Status
))
31 SecQos
.Length
= sizeof(SECURITY_QUALITY_OF_SERVICE
);
32 SecQos
.ImpersonationLevel
= ImpersonationLevel
;
33 SecQos
.ContextTrackingMode
= SECURITY_DYNAMIC_TRACKING
;
34 SecQos
.EffectiveOnly
= FALSE
;
36 ObjectAttributes
.Length
= sizeof(OBJECT_ATTRIBUTES
);
37 ObjectAttributes
.RootDirectory
= 0;
38 ObjectAttributes
.ObjectName
= NULL
;
39 ObjectAttributes
.Attributes
= 0;
40 ObjectAttributes
.SecurityDescriptor
= NULL
;
41 ObjectAttributes
.SecurityQualityOfService
= &SecQos
;
43 Status
= NtDuplicateToken(ProcessToken
,
49 if (!NT_SUCCESS(Status
))
51 NtClose(ProcessToken
);
55 Status
= NtSetInformationThread(NtCurrentThread(),
56 ThreadImpersonationToken
,
59 NtClose(ImpersonationToken
);
60 NtClose(ProcessToken
);