Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > getting info from Active Directory

Reply
Thread Tools

getting info from Active Directory

 
 
WIWA
Guest
Posts: n/a
 
      12-02-2004
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 Dvor (just a test name)
is returned as Dvor. 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


 
Reply With Quote
 
 
 
 
Howard
Guest
Posts: n/a
 
      12-02-2004

"WIWA" <(E-Mail Removed)> wrote in message
news:41af8f5d$0$25072$(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting user password from Active Directory Diego F. ASP .Net 6 05-31-2007 04:42 PM
asking info form ASP.NET 2.0 to Windows Active Directory Lucky ASP .Net 1 07-10-2006 12:57 PM
Getting Full NAME from Active Directory Patrick Olurotimi Ige ASP .Net 0 03-08-2005 06:37 AM
Getting Roles from Active Directory Patrick.O.Ige ASP .Net Security 0 10-27-2004 05:33 AM
Active Directory Search fails ("The directory service is unavailab ejcosta ASP .Net Security 2 10-08-2004 09:57 AM



Advertisments