Am working with windows server I want to create active directory lightweight service user by c++ ie, By c++ using ldap connection. My server runs in virtual box and i set the network adapter to be bridged network and it connects to the network just fine. Now when i used the code from microsoft documentation the ldap bind is not connecting .The error am getting is an operation error occured.
#include "atlbase.h"
#include "activeds.h"
int main(int argc, char* argv[])
{
HRESULT hr;
IADsContainer* pCont;
IDispatch* pDisp = NULL;
IADs* pUser;
// Initialize COM before calling any ADSI functions or interfaces.
CoInitialize(NULL);
hr = ADsGetObject(L"LDAP://ABC.local",
IID_IADsContainer,
(void**)&pCont);
if (!SUCCEEDED(hr))
{
return 0;
}
//-----------------
// Create a user
//-----------------
hr = pCont->Create(CComBSTR("user"), CComBSTR("cn=jeffsmith"), &pDisp);
// Release the container object.
pCont->Release();
if (!SUCCEEDED(hr))
{
return 0;
}
hr = pDisp->QueryInterface(IID_IADs, (void**)&pUser);
// Release the dispatch interface.
pDisp->Release();
if (!SUCCEEDED(hr))
{
return 0;
}
// Commit the object data to the directory.
pUser->SetInfo();
// Release the object.
pUser->Release();
CoUninitialize();
}
This is the code am using to check for successful connection. Any help will be really useful thank you.