Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ldap question 1

Status
Not open for further replies.

refulgent

IS-IT--Management
Jun 12, 2001
24
0
0
US
Hi Guys,

I am not sure i got the right forum..but my question is this..
I am looking for a code to retrieve user id from LDAP given that first name and last name are provided.

Thank you in advance,

kate
 
Hi Kate,

maybe the following example gives you some support:

HRESULT hr;
CoInitialize(NULL);

IADsContainer *pCont=NULL;

hr = ADsGetObject(L"LDAP://DC=windows2000,DC=nttest,DC=microsoft,DC=com",
IID_IADsContainer,
(void**) &pCont );

//////////////////////////////////////////////////////////////////////
// Get the child from the container.
// Note in the LDAP provider you can go down more than one level.
//////////////////////////////////////////////////////////////////////
IDispatch *pDisp = NULL;
IADs *pADs = NULL;
hr = pCont->GetObject(L"user", L"CN=Mike Smith, OU=DSys", &pDisp );
pCont->Release();

hr = pDisp->QueryInterface( IID_IADs, (void**) &pADs );
pDisp->Release();

// Do something with pADs here.
pADs->Release();

CoUninitialize();


This example was taken from Microsoft's MSDN.

Kind regards,
Kridy
_____________
kridy@web.de
 
Hi Kridy,

Thank you for reply!
I got as far as retrieveing all of the information about the user when i enter his name
I used printLDIF() for that...do you know how can i retrieve only the users mail id?
(if user name is Jane Doe her mail id would be jdoe)

Thanks,

Kate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top