1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// Link with Activeds.lib and Adsiid.lib files.
#include <stdio.h>
#include <activeds.h>
#include <comdef.h>
#include <Iads.h>
#include <Adshlp.h>
#include <atlbase.h>
int main(int argc, char* argv[])
{
IADs *pADs = NULL;
IADsUser *pADsUser = NULL;
IADsClass *pCls = NULL;
CComBSTR sbstr;
IADsUser *pUser;
BSTR bstr;
// initialize COM
HRESULT hr = CoInitialize(NULL);
if (hr != S_OK) { return 0; }
hr = ADsGetObject(L"WinNT://*NomServeur*/*NomUtilisateurActiveDirectory*",IID_IADsUser,(void**)&pUser);
hr = pUser->get_FullName(&bstr);
printf("Nom Affiche: %S\n", bstr);
hr = pUser->get_GUID(&bstr);
printf("GUID: %S\n", bstr);
hr = pUser->get_EmailAddress(&bstr);
printf("Mail: %S\n", bstr);
system("pause");
return 0;
} |
Partager