getting info from Active Directory

Discussion in 'C++' started by WIWA, Dec 2, 2004.

  1. WIWA

    WIWA Guest

    Hello,

    I have written a program that gets information from Active Directory. This
    is the function I'm using:

    void ADSysGetUserName(IADsADSystemInfo * pSys, char * data) {
    HRESULT hr;
    BSTR bstr;
    hr = pSys->get_UserName(&bstr);
    if (SUCCEEDED(hr)) {
    sprintf((char*)data, "%S", bstr);
    }
    SysFreeString(bstr);
    }

    I call it using:

    char temp[500];
    ADSysGetComputerName(pSys, temp);

    The problem I'm getting is that when a user's name contains special
    characters (such as éèöü ...) and I'm getting it, it modifies those
    characters. In the table below, you can see that Düvoçréè (just a test name)
    is returned as D³voþrÜÞ. The values in the left column are the correct ASCII
    values.


    68 D D
    252 ³ ü
    118 v v
    111 o o
    231 þ ç
    114 r r
    233 Ú é
    232 Þ è


    I was always under the impression that a char could also handle these
    special characters. Does anyone know what is wrong here? Should I use
    another type. Could anyone provide me with an example?

    Thanks in advance,

    WiWa
     
    WIWA, Dec 2, 2004
    #1
    1. Advertising

  2. WIWA

    Howard Guest

    "WIWA" <> wrote in message
    news:41af8f5d$0$25072$...
    > Hello,
    >
    > I have written a program that gets information from Active Directory. This
    > is the function I'm using:
    >
    > void ADSysGetUserName(IADsADSystemInfo * pSys, char * data) {
    > HRESULT hr;
    > BSTR bstr;
    > hr = pSys->get_UserName(&bstr);
    > if (SUCCEEDED(hr)) {
    > sprintf((char*)data, "%S", bstr);
    > }
    > SysFreeString(bstr);
    > }
    >
    > I call it using:
    >
    > char temp[500];
    > ADSysGetComputerName(pSys, temp);
    >
    > The problem I'm getting is that when a user's name contains special
    > characters (such as ihv| ...) and I'm getting it, it modifies those
    > characters. In the table below, you can see that D|vogrih (just a test
    > name) is returned as D3vo~r\^. The values in the left column are the
    > correct ASCII values.
    >
    >
    > 68 D D
    > 252 3 |
    > 118 v v
    > 111 o o
    > 231 ~ g
    > 114 r r
    > 233 Z i
    > 232 ^ h
    >
    >
    > I was always under the impression that a char could also handle these
    > special characters. Does anyone know what is wrong here? Should I use
    > another type. Could anyone provide me with an example?
    >
    > Thanks in advance,
    >
    > WiWa


    Are the values changing, or are they correct but your display of them as
    text (using printf) is incorrect? Run it in a debugger and see whether you
    get the correct values. Also,you'll probably want to use unsigned char for
    whatever it is they get stored in, since you've got values that are greater
    than 127. (And I have no idea what a BSTR is... nor any of that other
    stuff. Looks like Microsoft-specific stuff. If you have problems specific
    to Microsoft, you might want to ask in one of their newsgroups.)

    -Howard
     
    Howard, Dec 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Olurotimi Ige

    Getting Full NAME from Active Directory

    Patrick Olurotimi Ige, Mar 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    506
    Patrick Olurotimi Ige
    Mar 8, 2005
  2. Diego F.
    Replies:
    6
    Views:
    64,838
    zullu
    May 31, 2007
  3. Lucky
    Replies:
    1
    Views:
    529
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Jul 10, 2006
  4. ejcosta
    Replies:
    2
    Views:
    898
    Eurico Costa
    Oct 8, 2004
  5. Patrick.O.Ige

    Getting Roles from Active Directory

    Patrick.O.Ige, Oct 27, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    126
    Patrick.O.Ige
    Oct 27, 2004
Loading...

Share This Page