Skip to content

Commit

Permalink
Added platform.win32.Advapi32.ImpersonateSelf
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.java.net/svn/jna~svn/trunk@1182 2f8a963e-d2e4-e7d0-97bf-ccb7fcea9d80
  • Loading branch information
nguillaumin committed Feb 3, 2011
1 parent 3de7eb5 commit 5bd2cba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Expand Up @@ -378,8 +378,17 @@ public boolean GetTokenInformation(
* @return
* If the function succeeds, the return value is nonzero.
*/
public boolean ImpersonateLoggedOnUser(
HANDLE hToken);
public boolean ImpersonateLoggedOnUser(HANDLE hToken);

/**
* The ImpersonateSelf function obtains an access token that impersonates the security
* context of the calling process. The token is assigned to the calling thread.
* @param ImpersonationLevel Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type
* that supplies the impersonation level of the new token.
* @return If the function succeeds, the return value is nonzero.
*/
public boolean ImpersonateSelf(int ImpersonationLevel);


/**
* The RevertToSelf function terminates the impersonation of a client application.
Expand Down
Expand Up @@ -801,4 +801,9 @@ public void testAdjustTokenPrivileges() {
assertTrue(Advapi32.INSTANCE.AdjustTokenPrivileges(hToken.getValue(), false, tp, 0, null, null));
assertTrue(Kernel32.INSTANCE.CloseHandle(hToken.getValue()));
}

public void testImpersonateSelf() {
assertTrue(Advapi32.INSTANCE.ImpersonateSelf(WinNT.SECURITY_IMPERSONATION_LEVEL.SecurityAnonymous));
assertTrue(Advapi32.INSTANCE.RevertToSelf());
}
}
2 changes: 1 addition & 1 deletion jnalib/release-notes.html
Expand Up @@ -2,7 +2,7 @@
<h2>Release 3.x.x</h2>
<h3>Features</h3>
<ul>
<li>Add <code>platform.win32.Advapi32.AdjustTokenPrivileges</code>, <code>platform.win32.Advapi32.LookupPrivilegeName</code>, <code>platform.win32.Advapi32.LookupPrivilegeValue</code>.
<li>Add <code>platform.win32.Advapi32.AdjustTokenPrivileges</code>, <code>platform.win32.Advapi32.LookupPrivilegeName</code>, <code>platform.win32.Advapi32.LookupPrivilegeValue</code>, <code>platform.win32.Advapi32.ImpersonateSelf</code>.
<li>Add <code>platform.win32.Advapi32.DuplicateTokenEx</code>, <code>platform.win32.Advapi32.CreateProcessAsUser</code>,
<code>platform.win32.Kernel32.GetExitCodeProcess</code>, <code>platform.win32.Kernel32.TerminateProcess</code>, <code>platform.win32.Kernel32.ReadFile</code>,
<code>platform.win32.Kernel32.CreatePipe</code>, <code>platform.win32.Kernel32.SetHandleInformation</code> and related constants / structures in <code>platform.win32.WinBase</code>
Expand Down

0 comments on commit 5bd2cba

Please sign in to comment.