|
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
|
|
|
|
|
Hemang Raval wrote: I am not getting any error for above code but at the same time not getting desired output.
Hemang Raval wrote: nStatus = NetUserSetInfo(NULL,pswzUser,dwLevel1005,(LPBYTE)&ui1005,NULL);
What is the value of nStatus after the call? Is it equal to NERR_Success ?
Can you try this?
if(NetUserSetInfo(NULL, pswzUser,
dwLevel1005, LPBYTE)&ui1005, NULL)!=NERR_Success)
AfxMessageBox(_T("NetUserSetInfo() Failed!"));
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I have console based appliacation. So i used following code to determine it.
nStatus = NetUserSetInfo(NULL,pswzUser,dwLevel1005,(LPBYTE)&ui1005,NULL);
if(nStatus != NERR_Success)
fprintf(stderr, "NetUserSetInfo failed with error: %d\n", nStatus);
And above code gives me following error.
NetUserSetInfo failed with error: 87
Any suggestion. Please help me.
Thanks,
Hemang
|
|
|
|
|
Why don't you through the documentation and find out what the error means? The return value can be one of the 9 return codes provided in the documentation in case of failure. I don't feel like offering any help if you can't even look up the documentation.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Thanks for your reply. Now onwards, i look into documents before posting
Thanks,
Hemang
|
|
|
|
|
Good to know. Try it out and let me know if you have more problems then.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I am getting ERROR_INVALID_PARAMETER as return error code. Description of cod says that one of the functions parameters is invalid. Now i am not getting clue about whic parameter is wrong.
can you please point me out now how to proceed in order to resolve it. You have helped me a lot. So thanks for it.
Regards,
Hemang
|
|
|
|
|
Hemang Raval wrote: nStatus = NetUserSetInfo(NULL,pswzUser,dwLevel1005,(LPBYTE)&ui1005,NULL);
Have you verified the second argument is what you expect? Have you tried a string literal?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
hi, all, the EDIT have already add ES_PASSWORD, but I want to Input DoubleChar, how to do it?
|
|
|
|
|
619345142 wrote: ...but I want to Input DoubleChar...
What's that?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
eg. Chinese,
I can't not input chinese when the EDIT has ES_PASSWORD style
|
|
|
|
|
This is not an answer to your question, but I'm just curious. Don't take it personally.
Are you setting a Chinese password?
It must be difficult to type those characters even when you see them. How possibly can you be sure of what's being typed when all you see would be asterisks.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: It must be difficult to type those characters even when you see them. How possibly can you be sure of what's being typed when all you see would be asterisks.
Usually you have to type two times the new password. For a Chinese one, you have to do it eight times.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Talk about living a tough life then.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Are you able to type in Chinese character into the control without password style at first? The app is fully Unicode?
I am able to type Chinese character into a CEdit control with and without password style. There's something else wrong I guess.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I am able to type Chinese character into a CEdit control with and without password style.
Just curious: what are you entering?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Just curious: what are you entering?
I don't know, but I pressed some random keys and this character[^] appeared. I may not be able to reproduce the thing though.
I promise never to set a Chinese password. No, really.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I don't know, but I pressed some random keys and this character[^] appeared
That's wonderful, let's play Mahjong!
BTW
Rajesh R Subramanian wrote: Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
Here the goal is Hijacking, of course.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hehe...
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hi all,
I have a project that uses unicode character set this snippet gives me an error:
CMimeMessage msg;
CoInitialize(0);
msg.SetSender(L"Administrator@redmap.com");
msg.SetSenderName(A2T("Redmap Networks"));
msg.AddRecipient(EmailAddress);
strValue = W2A(EmailAddress);
char dom[100]="";
int a = GetDomain(strValue.c_str(), dom);
if (a == 0){
strValue = dom;
msg.SetSubject(A2T("Download Notification"));
The bold part gives me errors and i found them here(atlmime.h):
inline BOOL SetSenderName(LPCTSTR szName, UINT uiCodePage = 0) throw()
{
if (szName == NULL)
return FALSE;
CHeapPtr<char> szNamePtr;
UINT nLen(0);
BOOL bRet = AtlMimeConvertString(m_spMultiLanguage, uiCodePage, szName, &szNamePtr, &nLen); if (bRet)
{
It seems that m_spMultiLanguage must be initialized, how do I do that?
I tried calling CoInitialize(0) before feeling up msg it wont work. Any advice?
Thanks,
Jayjay
|
|
|
|
|
What error did you get?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Its all ok now i just had to call coinitialize before creating an object.
|
|
|
|
|
I am in the process of reading the Book "Windows 95 with MFC" by Jeff Prosise. I am using the first edition of the book. I have compiled the program Paint4 which is the first example given of
the Document/View Architecture. I have copied the code directly from the CD. With two very minor
changes, the code compiles but fails to run. I am wondering, if this example is known to be bad. I looked around on the internet for a list of know errors in this book. However, I could not find such a list. I would like to get this example running, however, I am finding it hard to debug. The program bombs out inside MFC code.
Any advice?
Thanks
Bob
|
|
|
|
|
BobInNJ wrote: Any advice?
Does the program fail to start, or does it start and then stop before any window is drawn? How about setting a breakpoint in the app's InitInstance() to find out?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
BobInNJ wrote: I would like to get this example running, however, I am finding it hard to debug.
Maybe we could help with that, however you should be more detailed about the runtime error.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|