Click here to Skip to main content
15,904,156 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Monitoring network traffic on LAN using VC++ Pin
Mark Salsbery17-Oct-08 5:02
Mark Salsbery17-Oct-08 5:02 
Questionget printer status............ Pin
ani_ikram15-Oct-08 20:38
ani_ikram15-Oct-08 20:38 
QuestionRe: get printer status............ Pin
David Crow16-Oct-08 3:08
David Crow16-Oct-08 3:08 
QuestionRegarding NetUserAdd Pin
H4u3215-Oct-08 19:25
H4u3215-Oct-08 19:25 
AnswerRe: Regarding NetUserAdd Pin
Rajesh R Subramanian15-Oct-08 21:09
professionalRajesh R Subramanian15-Oct-08 21:09 
GeneralRe: Regarding NetUserAdd Pin
H4u3215-Oct-08 21:37
H4u3215-Oct-08 21:37 
GeneralRe: Regarding NetUserAdd Pin
Rajesh R Subramanian15-Oct-08 22:01
professionalRajesh R Subramanian15-Oct-08 22:01 
GeneralRe: Regarding NetUserAdd Pin
H4u3215-Oct-08 23:25
H4u3215-Oct-08 23:25 
I am sending the code snippet that i am using to change account type from admin to limited/noraml user. The user that i am trying to restrict has been created as admin.

her is the code

int getAdminNumber(int argc, wchar_t *argv[], LPWSTR user)
{
DWORD dwLevel = 2;

LPUSER_INFO_0 pBuf = NULL;
LPUSER_INFO_2 pBuf2 = NULL;

NET_API_STATUS nStatus;

LPTSTR sStringSid = NULL;

wprintf(L"\nCalling NetUserGetinfo with Servername=%s Username=%s Level=%d\n", argv[1], user, dwLevel);

nStatus = NetUserGetInfo(argv[1], user, dwLevel, (LPBYTE *) & pBuf);


if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
pBuf2 = (LPUSER_INFO_2) pBuf;
wprintf(L"\tUser account name: %s\n", pBuf2->usri2_name);
wprintf(L"\tPrivilege level: %d\n", pBuf2->usri2_priv);
if (pBuf2->usri2_priv == 2)
cnt++;
if(strcmp((char *)pBuf2->usri2_name, (char *)user) ==0)
ChangeUserPrivilege(pBuf2->usri2_name, pBuf2->usri2_priv);
}
}
else
fprintf(stderr, "NetUserGetinfo failed with error: %d\n", nStatus);



return 0;
}


void ChangeUserPrivilege(LPWSTR csUser, DWORD csPrivilege)
{
NET_API_STATUS nStatus;

USER_INFO_1005 ui1005;
DWORD dwLevel1005 = 1005;
DWORD dwPrivilege;

wchar_t *pswzUser = csUser;

if(csPrivilege == 2) dwPrivilege = USER_PRIV_USER;

ui1005.usri1005_priv = dwPrivilege;
nStatus = NetUserSetInfo(NULL,pswzUser,dwLevel1005,(LPBYTE)&ui1005,NULL);
}

I am not getting any error for above code but at the same time not getting desired output.

Any help would be greatly appreciated.

Thanks
Hemang
GeneralRe: Regarding NetUserAdd Pin
Rajesh R Subramanian16-Oct-08 1:13
professionalRajesh R Subramanian16-Oct-08 1:13 
GeneralRe: Regarding NetUserAdd Pin
H4u3216-Oct-08 2:20
H4u3216-Oct-08 2:20 
GeneralRe: Regarding NetUserAdd Pin
Rajesh R Subramanian16-Oct-08 2:33
professionalRajesh R Subramanian16-Oct-08 2:33 
GeneralRe: Regarding NetUserAdd Pin
H4u3216-Oct-08 2:36
H4u3216-Oct-08 2:36 
GeneralRe: Regarding NetUserAdd Pin
Rajesh R Subramanian16-Oct-08 2:59
professionalRajesh R Subramanian16-Oct-08 2:59 
GeneralRe: Regarding NetUserAdd Pin
H4u3216-Oct-08 3:17
H4u3216-Oct-08 3:17 
QuestionRe: Regarding NetUserAdd Pin
David Crow17-Oct-08 5:00
David Crow17-Oct-08 5:00 
Questionhi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
61934514215-Oct-08 17:18
61934514215-Oct-08 17:18 
QuestionRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
David Crow15-Oct-08 17:30
David Crow15-Oct-08 17:30 
AnswerRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
61934514215-Oct-08 18:23
61934514215-Oct-08 18:23 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
Rajesh R Subramanian15-Oct-08 20:59
professionalRajesh R Subramanian15-Oct-08 20:59 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
CPallini15-Oct-08 22:01
mveCPallini15-Oct-08 22:01 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
Rajesh R Subramanian15-Oct-08 22:11
professionalRajesh R Subramanian15-Oct-08 22:11 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
Rajesh R Subramanian15-Oct-08 22:09
professionalRajesh R Subramanian15-Oct-08 22:09 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
CPallini15-Oct-08 22:18
mveCPallini15-Oct-08 22:18 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
Rajesh R Subramanian15-Oct-08 22:25
professionalRajesh R Subramanian15-Oct-08 22:25 
GeneralRe: hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it? Pin
CPallini15-Oct-08 23:16
mveCPallini15-Oct-08 23:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.