469,579 Members | 1,161 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

getting info from Active Directory

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
Jul 22 '05 #1
1 3243

"WIWA" <wi**@yahoo.com.au> wrote in message
news:41***********************@news.skynet.be...
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
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Buddy Ackerman | last post: by
reply views Thread by Kenneth Keeley | last post: by
1 post views Thread by dhnriverside | last post: by
9 posts views Thread by =?Utf-8?B?RGVubmlz?= | last post: by
11 posts views Thread by Armin Zingler | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.