How to Enable/Disable Users thro' C++ or any code

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2004
Posts: 15
Reputation: shalin is an unknown quantity at this point 
Solved Threads: 0
shalin's Avatar
shalin shalin is offline Offline
Newbie Poster

How to Enable/Disable Users thro' C++ or any code

 
0
  #1
Jul 16th, 2004
Hi All,

I want to enable/disable users who logged in Domain Name Server (DNS).
Through VC++ code.
If anyone has idea regarding this please reply me asap.

Thanks in advance for u r reply.

Regards,
Shalin.
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 141
Reputation: meabed is on a distinguished road 
Solved Threads: 3
Team Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #2
Jul 17th, 2004
Real Eyes Realize Real Lies
My Resume
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 15
Reputation: shalin is an unknown quantity at this point 
Solved Threads: 0
shalin's Avatar
shalin shalin is offline Offline
Newbie Poster

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #3
Jul 19th, 2004
Originally Posted by meabed
http://www.microsoft.com/resources/d..._ovr_Tools.asp
check this link dude ..

Thanks you for u r reply ,
this link is very useful for me.

regards,
Shalin
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 141
Reputation: meabed is on a distinguished road 
Solved Threads: 3
Team Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #4
Jul 19th, 2004
np dude
Real Eyes Realize Real Lies
My Resume
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 15
Reputation: shalin is an unknown quantity at this point 
Solved Threads: 0
shalin's Avatar
shalin shalin is offline Offline
Newbie Poster

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #5
Jul 27th, 2004
Hi all,

Finaly I got the answer & here is the code in VC++.
Please Insert the ACTIVEDS.LIB & ADSIID.LIB files in your project.

Regards
Shashi Pawar.
//================= CODE =======================

#include "stdafx.h"
#include "ActiveDir.h"
#include "Activeds.h"
#include <comdef.h>
#include <Iads.h>
#include <Adshlp.h>


int main()
{

HRESULT hr = S_OK;
IADsContainer *pCont = NULL;
CoInitialize(NULL);

hr = ADsGetObject(L"WinNT://DOMAIN_NAME/COMP_NAME",
IID_IADsContainer, (void**) &pCont );
//Put your domain name & computer name.



if ( !SUCCEEDED(hr) )

{
return hr;
}

_variant_t var;
IEnumVARIANTPtr pEnum;
ADsBuildEnumerator (pCont,&pEnum);
int cnt=0;
ULONG ulFetched = 0L;

_variant_t vChild;
while((SUCCEEDED(ADsEnumerateNext(pEnum, 1, &vChild, &ulFetched)) && ulFetched==1))
{

IADsUser *pADs = NULL;
HRESULT hr = S_OK;


hr = V_DISPATCH(&vChild)->QueryInterface(IID_IADsUser, (void**)&pADs);
if(hr!=S_OK)
break;

BSTR bstrName;
pADs->get_Name(&bstrName);//stores the Usernames in a string.
CString csName=bstrName;

SysFreeString(bstrName);
printf("%s\n",csName);

if (csName == "User_Name")//put username here
hr = pADs ->put_AccountDisabled(VARIANT_FALSE);//TRUE for disable FALSE for enable the account.
hr = pADs ->SetInfo (); //To commit the operation
exit(0);

}

pADs->Release();//IADs user list
pCont->Release ();//free the objects container
}

}
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 1,620
Reputation: kc0arf is a jewel in the rough kc0arf is a jewel in the rough kc0arf is a jewel in the rough 
Solved Threads: 51
Team Colleague
kc0arf kc0arf is offline Offline
Posting Virtuoso

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #6
Jul 29th, 2004
Hello,

Great on the code!

Just wanted to clarify that no one logs in through DNS. DNS (Domain Naming Service) is a "yellow pages" of information concerning servers and computers on the internet, or in a private network. DNS maps the name www.apple.com to 17.x.y.z You will not receive a login prompt from a DNS server.

What you are talking about here is Active Directory, a pure Microsoft Thing. While hooks are becoming available for Mac and Linux to login to Active Directory, it is mainly a Windoze operation.

Code looks great though! I wonder if it would work from a linux box, assuming that the other libraries are available.

Christian
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 15
Reputation: shalin is an unknown quantity at this point 
Solved Threads: 0
shalin's Avatar
shalin shalin is offline Offline
Newbie Poster

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #7
Jul 30th, 2004
Originally Posted by kc0arf
Hello,

Great on the code!

Just wanted to clarify that no one logs in through DNS. DNS (Domain Naming Service) is a "yellow pages" of information concerning servers and computers on the internet, or in a private network. DNS maps the name www.apple.com to 17.x.y.z You will not receive a login prompt from a DNS server.

What you are talking about here is Active Directory, a pure Microsoft Thing. While hooks are becoming available for Mac and Linux to login to Active Directory, it is mainly a Windoze operation.

Code looks great though! I wonder if it would work from a linux box, assuming that the other libraries are available.

Christian


hi,
U r right, it is for active directory users a pure windows thing,
I didnt tried such thing on linux, may be their are some libraries available.

Regards,
Shalin
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1
Reputation: Zzzaru is an unknown quantity at this point 
Solved Threads: 0
Zzzaru Zzzaru is offline Offline
Newbie Poster

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #8
Sep 13th, 2008
Very, Good! This is help me/
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,400
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 113
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: How to Enable/Disable Users thro' C++ or any code

 
0
  #9
Sep 13th, 2008
You just posted in a 4 year old thread, read THIS before posting again, incase you missed it..
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC