how to check a specfied user whether in administrators group
It seems UserInfo:GetAccountType can only check current loggon user. But I want to check any user.How to make that?
thx
Archive: how to check a specfied user whether in administrators group
how to check a specfied user whether in administrators group
It seems UserInfo:GetAccountType can only check current loggon user. But I want to check any user.How to make that?
thx
I added a function to UserMgr.c (in http://nsis.sourceforge.net/archive/...le=UserMgr.zip )
I'm not a C/C++ programmer, so there might be quite some errors in it (not deleting and stuff like that), but it works for me right now.
int __declspec(dllexport) GetUserGroups(HWND hwndParent, int string_size,
char *variables, stack_t **stacktop,
extra_parameters *extra)
{
LPGROUP_USERS_INFO_0 ui = NULL;
DWORD dwLevel = 0;
DWORD dwError = 0;
NET_API_STATUS nStatus;
DWORD entriesRead = 0;
DWORD totalEntries = 0;
static char userid[256];
static char response[1024];
static WCHAR u_userid[256];
memset( u_userid, 0, sizeof( u_userid ) );
g_hwndParent=hwndParent;
EXDLL_INIT();
popstring(userid);
swprintf(u_userid, L"%S", userid);
nStatus = NetUserGetLocalGroups(NULL,
u_userid,
dwLevel,
LG_INCLUDE_INDIRECT,
(LPBYTE *)&ui,
MAX_PREFERRED_LENGTH,
&entriesRead,
&totalEntries);
if (nStatus != NERR_Success)
{
sprintf(userid, "ERROR %d", nStatus);
pushstring(userid);
NetApiBufferFree(ui);
return nStatus;
}
else
{
LPGROUP_USERS_INFO_0 pTmpBuf;
DWORD i;
DWORD dwTotalCount = 0;
if ((pTmpBuf = ui) != NULL)
{
//
// Loop through the entries;
// print the name of the global groups
// to which the user belongs.
//
for (i = 0; i < entriesRead; i++)
{
if (pTmpBuf == NULL)
{
sprintf(userid, "ERROR An access violation has occurred: %d", nStatus);
pushstring(userid);
NetApiBufferFree(ui);
return nStatus;
}
sprintf(response, "%S", pTmpBuf->grui0_name);
pushstring(response);
pTmpBuf++;
dwTotalCount++;
}
}
sprintf(response, "%d", dwTotalCount);
pushstring(response);
NetApiBufferFree(ui);
return STATUS_SUCCESS;
}
}
InitPluginsDir
UserMgr::GetUserGroups "SQLDebugger"
Pop $0
Push "$0"
Push "ERROR"
Call StrStr
Pop $1
StrCmp $1 "" +1 error
MessageBox MB_OK "Nr. results: $0"
loop:
StrCmp $0 "0" end
Pop $1
MessageBox MB_OK "Group: $1"
IntOp $0 $0 - 1
Goto loop
error:
MessageBox MB_OK "Error: $1"
end:
you guys good!£¡