All,
I am having a problem getting attributes of a user out of active directory. When I execute my query, I get a profile back (mine), and it tells me the attribute that I queried for, but the value is always null. Any ideas as to why this is?
// Open a connection with server.
hr = ADsOpenObject(L"LDAP://myServer",
szUsername,
szPassword,
ADS_SECURE_AUTHENTICATION,
IID_IDirectorySearch,
(void **)&pDSSearch);
LPWSTR pszAttr[] = { L"distinguishedName" };
ADS_SEARCH_HANDLE hSearch;
DWORD dwCount = 0;
DWORD dwAttrNameSize = sizeof(pszAttr)/sizeof(LPWSTR);
// Search for all objects with the 'cn' property that start with c.
hr = pDSSearch->ExecuteSearch(L"(&(objectClass=user)(objectCategory=person)(sAMAccountName=jjknack))",
pszAttr ,dwAttrNameSize,&hSearch );
while( pDSSearch->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS )
{
// Get the property.
hr = pDSSearch->GetColumn( hSearch, L"distinguishedName", &col );
// If this object supports this attribute, display it.
if ( SUCCEEDED(hr) )
{ //ADSTYPE_CASE_IGNORE_STRING
WriteMessageCharInt("ADsType: %d", col.dwADsType);
sprintf(tOP, "got attr: %S", col.pszAttrName);
WriteMessageChar(tOP);
WriteMessageCharInt("NUM VALS: %d", col.dwNumValues);
sprintf(tOP, "The distinguishedName property:%s", col.pADsValues->CaseIgnoreString);
WriteMessageChar(tOP);
pDSSearch->FreeColumn( &col );
OUTPUT:
ADsType: 1
got attr: distinguishedName
NUM VALS: 1
The distinguishedName propertynull)
All of the value types under col.pADsValues are (null) as well.
I am having a problem getting attributes of a user out of active directory. When I execute my query, I get a profile back (mine), and it tells me the attribute that I queried for, but the value is always null. Any ideas as to why this is?
// Open a connection with server.
hr = ADsOpenObject(L"LDAP://myServer",
szUsername,
szPassword,
ADS_SECURE_AUTHENTICATION,
IID_IDirectorySearch,
(void **)&pDSSearch);
LPWSTR pszAttr[] = { L"distinguishedName" };
ADS_SEARCH_HANDLE hSearch;
DWORD dwCount = 0;
DWORD dwAttrNameSize = sizeof(pszAttr)/sizeof(LPWSTR);
// Search for all objects with the 'cn' property that start with c.
hr = pDSSearch->ExecuteSearch(L"(&(objectClass=user)(objectCategory=person)(sAMAccountName=jjknack))",
pszAttr ,dwAttrNameSize,&hSearch );
while( pDSSearch->GetNextRow( hSearch) != S_ADS_NOMORE_ROWS )
{
// Get the property.
hr = pDSSearch->GetColumn( hSearch, L"distinguishedName", &col );
// If this object supports this attribute, display it.
if ( SUCCEEDED(hr) )
{ //ADSTYPE_CASE_IGNORE_STRING
WriteMessageCharInt("ADsType: %d", col.dwADsType);
sprintf(tOP, "got attr: %S", col.pszAttrName);
WriteMessageChar(tOP);
WriteMessageCharInt("NUM VALS: %d", col.dwNumValues);
sprintf(tOP, "The distinguishedName property:%s", col.pADsValues->CaseIgnoreString);
WriteMessageChar(tOP);
pDSSearch->FreeColumn( &col );
OUTPUT:
ADsType: 1
got attr: distinguishedName
NUM VALS: 1
The distinguishedName propertynull)
All of the value types under col.pADsValues are (null) as well.