473,468 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Buddy Ackerman | last post by:
I have an application where the client wants AD integration. The application requires that the user accounts reside in the app's database. The application is a (.NET) webservices based app where...
0
by: Kenneth Keeley | last post by:
Hi, I am looking for a sample of how to get the password last set for a user in active directory in a format that we can read. I am using ASP.Net and C# I have got as far as get the value. but I...
1
by: dhnriverside | last post by:
Hi guys Cant find what the Property names are for accessing a few bits of the Active Directory User Info.. I'm looking for Address Mobile Telephone
1
by: Lucky | last post by:
hi guys, after long long efforts i got access to the active directory for "Intigrated windows authentication". now i', suppose to get access the network resources. the problem is i'm getting...
3
by: Chakkaradeep | last post by:
Hi all, How to retrieve Users Names and also restrict internet access to a specific users using C# ? Thanks. Regards, C.C.Chakkaradeep
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
9
by: =?Utf-8?B?RGVubmlz?= | last post by:
I am trying to get all the user info in my home network domain using WMI but the below code returns nothing. I know the domain name I pass is correct, i.e., "mshome". I cut and pasted this code...
0
by: markswart | last post by:
Pull Active Directory 2003 Info into outgoing Email I would Like to attach users in active directory 2003 information to there outgoing email Name Surname ect. Please Help Mark
11
by: Armin Zingler | last post by:
"Bill Schanks" <wschanks@gmail.comschrieb Try to execute lvMembers.beginupdate before filling and lvMembers.endupdate
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.