CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2005
    Posts
    5

    ADSI VC++/ geeting the DN of a User

    Hi,
    I wrote a C++ program to get the DN of a user in ActiveDirectory. The program is fetching the object successfully and identifying the attribute "distinguishedname" correctly. But when I'm trying to print the value of "distinguishedname" it is printing <null>. I'm not sure whether this is a problem with my code or with the AD setup I'm using. I'm here posting the code. Please check that and tell if there is something wrong with the code.
    I have attached the source code I'm using.

    please reply soon.

    regards,
    rajesh.
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2004
    Posts
    184

    Re: ADSI VC++/ geeting the DN of a User

    I think you need to reference the returned data differently. At least in the sample, the return value appears to be an array of items. Also, the DN is referenced as a ".DNString".

    from MSDN:
    Code:
    // Get the data for this column
    wprintf(L"%s\n",col.pszAttrName);
    switch (col.dwADsType)
    {
       case ADSTYPE_DN_STRING:
         for (x = 0; x< col.dwNumValues; x++)
         {
            wprintf(L"  %s\r\n",col.pADsValues[x].DNString);
         }
         break;
       case ADSTYPE_CASE_EXACT_STRING:
       case ADSTYPE_CASE_IGNORE_STRING:
       case ADSTYPE_PRINTABLE_STRING:
       case ADSTYPE_NUMERIC_STRING:
       case ADSTYPE_TYPEDNAME:
       case ADSTYPE_FAXNUMBER:
       case ADSTYPE_PATH:
       case ADSTYPE_OBJECT_CLASS:
         for (x = 0; x< col.dwNumValues; x++)
         {
            wprintf(L"  %s\r\n",col.pADsValues[x].CaseIgnoreString);
         }
         break;
    
         // rest of code here...........
    }
    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured