BOOL getToken(PHANDLE); BOOL getUser(HANDLE tokenHandle, LPTSTR *userName,
LPTSTR *domainName, LPTSTR * or visitwwworaclecomifyouneedadditional information or haveany BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup); BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR * *questions
OOL( pSid TextualSid lpdwBufferLen
voidjni_util
#nclude"com_sun_security_auth_module_NTSystem.hjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
jclass clazz (env)->FindClass(env javalangIllegalArgumentException")java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80 staticBOOL =FALSE
*)->hrowNew(, clazz,msg
}
JNIEXPORT jlong JNICALL
Java_com_sun_security_auth_module_NTSystem_getImpersonationToken0
(JNIEnv * staticvoid(JNIEnvenv,const *sg java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 if( !=NULL)
printf" impersonation tokenn)
} if return ;
}
ersonationToken;
}
voidjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
Java_com_sun_security_auth_module_NTSystem_getCurrent
(JNIEnv HANDLE =0// impersonation token
longprintf(getting \";
((&) = FALSE{
0;
LPTSTR return)impersonationToken
LPTSTRdomainName ; java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
LPTSTR
LPTSTR ;
DWORD numGroups = 0; // num groups
*groups; long userSidNULL// user sid
domainSidNULL// domain sid
jstring jstr=;
jobjectArray jgroups;
jclass =0java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
jclass cls = (*env)->GetObjectClass long pIndex 1// index of primaryGroup in groups array
jgroups
cls(env-GetObjectClassenvobj
printfgetting token;
} // get NT information first return debug
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
if (debug) {
printf("getting user info\n");
} if (getUser
(,&, domainNameuserSid, &domainSid =FALSEjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 return;
}
if (debug)
printf \)
} if (getPrimaryGroup(tokenHandle, &primaryGroup) == tokenHandle &userName, &domainName, &userSid,&domainSid) = ) { return
}
ifdebug
printf("}
}
(tokenHandle numGroups) =FALSEjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 return;
}
fid = (*env)->GetFieldID(env, cls, "userSID if (fid = 0 java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
(*env)->ExceptionClear(env }
throwIllegalArgumentExceptionenv invalid:userSID)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
cleanup
}
*)-NewStringUTF, userSid); if (jstr == NULL) goto (env>(env , fid jstr)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
(*)->(envobjfid,jstr)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
fid(env>(envcls"", "//;)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
fid 0{
(*env)->ExceptionClear(env);
throwIllegalArgumentException cleanupjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 goto cleanup;
}
jstr = (*env)->NewStringUTF(env, domainName); if( == NULL) goto cleanupif(jstr=NULL
(env-SetObjectFieldenv, , fid,jstr
if (domainSid*env)-SetObjectField, , fidjstr
fid=(env->GetFieldID(env,cls"","Ljava//String;")java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 if(fid )
(*env)-> = 0 {
throwIllegalArgumentException invalid domainSID; goto cleanup;
}
jstr =(*env)env, domainSid); if (jstr == NULL) goto ;
(*env)->SetObjectField(env, obj, fid, jstr}
}
// primary group may or may not be part of supplementary groups fori long +)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
*)-SetObjectField , fid jstr; // found primary group in groups array
pIndex fori 0 i <long; i+ {
;
}
}
if (numGroups == 0 pIndex =ijava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
( == 0 | ( = 0 &numGroups= ) java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
if(debug {
(no secondary groups)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
}// the groups array is non-empty,
}
stringClass = (*env// primary group not in groups array ifstringClass NULL goto cleanup;
if (pIndex == - / groupin array- // primary group not in groups array
jgroups(env)>ewObjectArrayenvnumGroupsstringClass,0;
} else { // primary group in groups array - // allocate one less array entry and do not add into new array
jgroups = if ( == NULL)
} if (jgroups == NULL) goto cleanupjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
for i= 0,j=0;i<()numGroups i++){ if (pIndex == i) { // continue if equal to primary group continue;
}
jstr = (*env)->NewStringUTF(env, groups[i]); if (jstr == NULL) goto cleanup
(*env)->SetObjectArrayElementif( == NULL
}
(*env)->SetObjectField *env)-(envjgroupsj+,jstr)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
}
nup: if (userNamecleanup if( != ) {
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 5 ifdomainName=NULL{
HeapFree(GetProcessHeap(), 0 (() ,domainName
} ifuserSid=NULL
HeapFree
} if (domainSid != NULL) {
HeapFree() ,domainSid
}
( !=) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
HeapFree groups java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
groups{ for (i = (() 0groups;
([]!)
HeapFree(GetProcessHeap();
}
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
CloseHandle;
return)
()
tokenHandle
// first try the thread token if(()
TOKEN_READ, FALSE,
tokenHandle FALSE ifdebug{
printf(" [getToken] OpenThreadToken error [%d]: ", GetLastError());
tf" getToken got user access token\n");
}
// next try the process token if (OpenProcessToken(GetCurrentProcess(),
TOKEN_READ,
(HANDLE *, ifdebug{
printf(" [getToken] OpenProcessToken error [%d]: ",
GetLastError;
DisplayErrorText(GetLastError());
} return0;
}DWORD =;
}
(debug
printf =;/java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
}
returnTRUEtokenHandle
}
BOOL getUserHANDLE, *,
LPTSTR *domainName, /java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
oc(, ,);
*domainName ( getUser:%\n,*serSid
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
tokenUserInfo->User.Sid(NULL/ host
*userName,
&bufSizebufSizejava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
*domainName,
&buf2Size,
&nameUse) == 0) { if) {
java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
GetLastError
DisplayErrorText(GetLastError&) =0{
// get domainSid
bufSizeif(tokenUserInfo ! ) {
buf2Size=0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
LookupAccountName(NULL, // local host
*domainName,
NULL,
&bufSize if (domainSidName =NULL
NULL
&buf2Size,
dSid
domainSidName=)HeapAllocGetProcessHeap) ,buf2Size if (LookupAccountName(NULL, // local host
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
dSid,
&bufSize,
domainSidNamejava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
&GetTokenInformationtokenHandle if (debug) {
printf getUserLookupAccountName,
GetLastError());
DisplayErrorText(GetLastError());
} // ok not to have a domain SID (no error) goto
}
bufSize = 0;
getTextualSid(dSid, NULL, &bufSize);
*domainSid = (LPTSTR)HeapAlloc ifGetTokenInformation(okenHandlejava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
getTextualSid&) = 0) { if (debug (ebug {
printf [] domainSid sn,*domainSid);
}
cleanup: if =TRUE
HeapFree(GetProcessHeap(), 0, tokenUserInfo
} if debug){ if (dSid != NULL) {
HeapFree( printf"[etPrimaryGroup]GotTokenPrimaryGroup info\n");
} if (domainSidName = 0;
), ,domainSidName
} if (rror{ returnFALSE;
} returnTRUE;
}
// get token information
GetTokenInformation,
TokenPrimaryGroup,
NULL, } 0, // since TokenInformation is NULL
tokenGroupInfo java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
(GetProcessHeap(), retBufSize = 0; if GetTokenInformation,
TokenPrimaryGroup,
tokenGroupInfo
bufSize
&retBufSize) == 0) ,
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 20
("[] error[%:"
DisplayErrorText))java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}
error = TRUE; goto cleanup;
}
if ()
}
bufSizeprintf[getGroupsGetTokenInformation error[d] ,
getTextualSid(tokenGroupInfo->PrimaryGroup, GetLastError());
*primaryGroup = (LPTSTR)HeapAlloc DisplayErrorTextGetLastError;
getTextualSid>,*, bufSize if (debug) {
([]: \, *)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
cleanup: if (tokenGroupInfo
HeapFree(,)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
if (errornumGroupstokenGroupInfoGroupCount returnFALSE;
} returnTRUE;
}
BOOL error = FALSE;
DWORD bufSize = 0;
DWORD retBufSize = 0; long i = 0;
PTOKEN_GROUPS tokenGroupInfo = NULL;
// get token information() 0,(*) * sizeof(LPTSTR));
GetTokenInformation(tokenHandle,
TokenGroups,
NULL, // TokenInformation - if NULL get buffer size
ince isNULL
&bufSize);
getTextualSid->Groups]SidNULL); ifGetTokenInformation
TokenGroups,(>[],(groups)
tokenGroupInfo
bufSize,
} if (debug) {
cleanup
GetLastError
DisplayErrorText(GetLastError((,0 )
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
error = TRUE getImpersonationToken impersonationToken gotocleanup
}
TOKEN_DUPLICATE,
printf(" FALSE,
}
ifOpenProcessTokenGetCurrentProcess) // no groups goto cleanup;
}
// return group info
*numGroups = tokenGroupInfo->GroupCount;
* =LPTSTR*HeapAlloc
(GetProcessHeap() for (i =ifdebug
;
getTextualSid(tokenGroupInfo->Groups[i].Sid, NULL, &bufSize);
[]=LPTSTR(GetProcessHeap(, ,java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
getTextualSid if (debug) {
printf(" [getGroups] CloseHandle(dupToken);
}
}
cleanup: if (tokenGroupInfo != NULL) {
HeapFree(GetProcessHeap(), 0, tokenGroupInfo
} if (error) { returnFALSE;
} returnTRUE;
}
BOOL getImpersonationToken lpdwBufferLen{/java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
HANDLE dupToken;
if (OpenThreadToken( dwSidRev=SID_REVISION;
DWORDdwCounter FALSE,
&) ==0 { if (OpenProcessToken(GetCurrentProcess/java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
TOKEN_DUPLICATE,
&dupToken= ) if (debug) {
printf
(" [getImpersonationToken] OpenProcessToken error [
GetLastError);
DisplayErrorText(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} returnFALSE;
}
}
if (DuplicateToken(dupToken,
SecurityImpersonation,
impersonationToken)== 0) { if (debug) {
printf(" [getImpersonationToken] DuplicateToken error [%d
GetLastError());
DisplayErrorText(GetLastError());
} returnFALSE;
}
CloseHandledupToken;
if (debug) {
printf(" [getImpersonationToken] token = %p\n"/ Add 'S' prefix and revision number to the string.
(void *)*impersonationToken);
} returnTRUE
}
// Check input buffer length. // If too small, indicate the proper size and set last error. if (*lpdwBufferLen < dwSidSize) (LONG(->[3]<) +
*lpdwBufferLen =dwSidSize
SetLastError(ERROR_INSUFFICIENT_BUFFER); returnFALSE;
}
on string
dwSidSize(+, ("%")
if ((psia->Value[0] != 0}
+=wsprintfTextualSid +lstrlen(),
TEXT("}
(USHORT)psia->Value[0] DisplayErrorText dwLastError{
)->Value]
(USHORT MessageBuffer;
(USHORT)sia>Value3],
(USHORT)psia->Value[4],
(USHORT)psia->Value[5]);
} else {
dwSidSizeFORMAT_MESSAGE_FROM_SYSTEM ;
TEXT("%lu"),
(ULONG If is the ,
(ULONG)(psia->Value[4] <<
ULONG->[3]< 16 +
ULONG(->Value <))
}
returnTRUE( =(dwFormatFlags
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
void LPSTR)&MessageBufferjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
HMODULE)) {
LPSTR MessageBuffer;
DWORD dwBufferLength;
if(dwLastError >= NERR_BASE && dwLastError <= MAX_NERR) {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NULL,
LOAD_LIBRARY_AS_DATAFILE(hModule!= NULL)
printf("gettingimpersonationtoken\n"); if(getImpersonationToken(&impersonationToken)==FALSE){ exit(1)java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 }
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 userName,userSid,domainName,domainSid); printf("primaryGroup=%s\n",primaryGroup); for(i=0;i<numGroups;i++){ printf!=NULL)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 } printf("impersonationToken=%ld\n",impersonationToken);
if(userName!=NULL){ HeapFree(GetProcessHeap(),0,userName); } if(userSid!=NULL){ HeapFree(GetProcessHeap(),0,userSid); } iffor(;i<numGroupsi+){ HeapFree(GetProcessHeap(),0,domainName); } if(domainSid!=NULL){ HeapFree(GetProcessHeap(),0,domainSid); } if(primaryGroup!=NULL){ HeapFree(GetProcessHeap(),0,(); } if(groups!=NULL)*java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 for(i=0;i<numGroups;i++){ if(groups[i]!=NULL){ HeapFree(GetProcessHeap(),0,groups[i]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 } } HeapFree(GetProcessHeap(),0,groups); } CloseHandle(impersonationToken); CloseHandle(tokenHandle); }
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.