You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/05/01 10:57:10 UTC
svn commit: r770588 -
/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
Author: mturk
Date: Fri May 1 08:57:10 2009
New Revision: 770588
URL: http://svn.apache.org/viewvc?rev=770588&view=rev
Log:
Add internal token info function
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c?rev=770588&r1=770587&r2=770588&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Fri May 1 08:57:10 2009
@@ -145,6 +145,36 @@
return sidtype;
}
+LPVOID ACR_GetTokenInformation(JNIEnv *_E, HANDLE h,
+ TOKEN_INFORMATION_CLASS ic)
+{
+ LPVOID rv;
+ DWORD sz = 0;
+ DWORD rc;
+
+ GetTokenInformation(h, ic, NULL, sz, &sz);
+ if ((rc = GetLastError()) != ERROR_INSUFFICIENT_BUFFER) {
+ if(_E) {
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
+ ACR_FROM_OS_ERROR(rc));
+ }
+ return NULL;
+ }
+ if (!(rv = ACR_Malloc(_E, THROW_FMARK, sz))) {
+ return NULL;
+ }
+ if (!GetTokenInformation(h, ic, rv, sz, &sz)) {
+ rc = GetLastError();
+ if(_E) {
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
+ ACR_FROM_OS_ERROR(rc));
+ }
+ free(rv);
+ rv = NULL;
+ }
+ return rv;
+}
+
static void GetUserHomePath(LPWSTR buf, DWORD blen, PSID sid)
{
LPWSTR ssid = NULL;