The following functions mainly use NT, W2K Active Directory services some component interfaces, such as IADsContainer container, IADs, IADsUser interface.
1. Delete a user (from this machine)
BOOL __stdcall DeleteUser(char *username)
{
HRESULT hr;
IADsContainer *pContainer=NULL;
_bstr_t bstr;
DWORD ll_len=255;
char lbBuffer[255];
::GetComputerName(lbBuffer,&ll_len);
bstr="WinNT://"+_bstr_t (lbBuffer)+","+_bstr_t("computer");
//Initialize apartment thread
hr=CoInitialize(NULL);
hr= ADsGetObject(bstr,IID_IADsContainer,(void **)& ;pContainer);
pContainer->Delete(L"user",_bstr_t(username));
pContainer->Release();
CoUninitialize();
return FALSE ;
}
2, add a user
BOOL __stdcall AddUser(char *username,char *fullname,char *description)
{
HRESULT hr;
> IADsContainer * pContainer = NULL;
IADs * pADs = NULL;
IDispatch * pDisp = NULL;
_bstr_t bstr;
DWORD ll_len = 255;
char lbBuffer [255] ;
:: GetComputerName (lbBuffer, & ll_len);
bstr = "WinNT: //" + _bstr_t (lbBuffer) + "," + _bstr_t ( "computer");
//Initialize apartment thread
hr=CoInitialize(NULL);
hr= ADsGetObject(bstr,IID_IADsContainer,(void **)&pContainer);
hr=pContainer->Create(L"user", _bstr_t (username), & pDisp);
pContainer- & gt; Release ();
if (SUCCEEDED (hr!)) {return hr;}
hr = pDisp- >QueryInterface(IID_IADs, (void**) &pADs );
pDisp->Release();
if ( !SUCCEEDED(hr) ) { return 0;}
VARIANT var; br> VariantInit (& var);
var.vt = VT_BSTR;
var.bstrVal = _bstr_t (fullname);
pADs- & gt; Put (L "FullName", var);
VariantClear (& var);
var.vt = VT_BSTR;
var.bstrVal = _bstr_t (description);
pADs- & gt; Put (L "Description" ,var);
VariantClear(&var);
hr=pADs->SetInfo();
hr=pADs->Release();
CoUninitialize();
return FALSE;
}
3. Set user password
BOOL __stdcall SetUserPwd(char *username,char *pwd)
{
HRESULT hr;
IADsUser *pUser;
_bstr_t bstr;
DWORD ll_len=255;
char lbBuffer[255];
::GetComputerName(lbBuffer,&ll_len);
bstr = "WinNT: //" + _bstr_t (lbBuffer) + "/" + _bstr_t (username) + ", user";
file: //initialize apartment thread
hr = CoInitialize (NULL);
hr= ADsGetObject(bstr,IID_IADsUser,(void **)&pUser);
if (SUCCEEDED(hr))
{
hr=pUser->SetPassword( _bstr_t (pwd));
if (SUCCEEDED (hr))
{
CoUninitialize ();
return TRUE;
}
}
CoUninitialize () ;
return FALSE;
}
With the popularity of broadband networks and the construction of various types of residential netwo
First, the existing environment First of all, please add the Windows 2008 server to the original Wi
The scale of the network managed in the morning is rapidly expanding, and the number of computers is
Due to differences in living habits and geography, the format of time and date varies from region to
How to fix Windows installation
Add video compression for Win 2003
How to configure Windows Server 2003 as a LAN router
Nine features of Windows Server 2008 that are ignored
Configuring a NAT server in Win 2003
A simple way to view Win 2003 logs
Feel the future: longhorn4051 full experience (2)
Win7 finds the background running program
Setting up Windows Server Auto Login Note Security
Face the threat of ChromeOS Windows8 response strategy
Win2003 install WMP11 new steps big secret
Win10 update KB3140741 failed again: Start menu failure
DNF86 version of the swordsman brush flow skills plus points recommended
QQ mailbox independent password retrieval tutorial