473,473 Members | 3,363 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

check active user on XP S.O

Hi all,

I would like to know, how can I check the name of the current user that is
Log on in O.S XP.
Hi already try the

Environment.UserName.ToString();
but is not what i would like to appear,its abreviated,
like 'MJhonson', and and what i want is the complete name 'Michael Johnson'.
--
Thanks ,

Pedro
Oct 13 '06 #1
3 1541
Hello Pedro,

Use active directory for this

There are http://groups.google.com/groups/sear...tory+full+name
some threads where this topic was discussed

PHi all,
P>
PI would like to know, how can I check the name of the current user
Pthat is
PLog on in O.S XP.
PHi already try the
PEnvironment.UserName.ToString();
Pbut is not what i would like to appear,its abreviated,
Plike 'MJhonson', and and what i want is the complete name 'Michael
PJohnson'.
PPedro
P>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Oct 13 '06 #2
You can get the full name from Active Directory something like this:

using System.DirectoryServices;
string DomainUser =
System.Security.Principal.WindowsIdentity.GetCurre nt().Name.Replace("\","/");
DirectoryEntry ADEntry = new DirectoryEntry("WinNT://" + DomainUser);
string FullName = ADEntry.Properties("FullName").Value;

Or you can use P/Invoke to call the Win32 API:

[DllImport("Secur32.dll", CharSet = CharSet.Auto)]
static extern short GetUserNameEx (int nameFormat, StringBuilder
lpNameBuffer, ref int size);

int size = 1000;
StringBuilder bldr = new StringBuilder(size);
GetUserNameEx(3, bldr, ref size);

Pedro wrote:
Hi all,

I would like to know, how can I check the name of the current user that is
Log on in O.S XP.
Hi already try the

Environment.UserName.ToString();
but is not what i would like to appear,its abreviated,
like 'MJhonson', and and what i want is the complete name 'Michael Johnson'.
--
Thanks ,

Pedro
Oct 13 '06 #3
Hi

My code is :

string DomainUser =

System.Security.Principal.WindowsIdentity.GetCurre nt().Name.Replace(@"\","/");
DirectoryEntry ADEntry = new DirectoryEntry("WinNT://" +
DomainUser);
string FullName = ADEntry.Properties("FullName").value;
MessageBox.Show("FullName");

The error is :

Error 1 'System.DirectoryServices.DirectoryEntry.Propertie s' is a 'property'
but is used like a 'method'
--
Thanks ,

Pedro
"Chris Fulstow" wrote:
You can get the full name from Active Directory something like this:

using System.DirectoryServices;
string DomainUser =
System.Security.Principal.WindowsIdentity.GetCurre nt().Name.Replace("\","/");
DirectoryEntry ADEntry = new DirectoryEntry("WinNT://" + DomainUser);
string FullName = ADEntry.Properties("FullName").Value;

Or you can use P/Invoke to call the Win32 API:

[DllImport("Secur32.dll", CharSet = CharSet.Auto)]
static extern short GetUserNameEx (int nameFormat, StringBuilder
lpNameBuffer, ref int size);

int size = 1000;
StringBuilder bldr = new StringBuilder(size);
GetUserNameEx(3, bldr, ref size);

Pedro wrote:
Hi all,

I would like to know, how can I check the name of the current user that is
Log on in O.S XP.
Hi already try the

Environment.UserName.ToString();
but is not what i would like to appear,its abreviated,
like 'MJhonson', and and what i want is the complete name 'Michael Johnson'.
--
Thanks ,

Pedro

Oct 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: fr? | last post by:
Hi, i have a website , on wich users have to log in credentials are checked against mysql db some session vars are set during login for use somewhere else in the code. Is there a way to...
4
by: Geir Baardsen | last post by:
Hi! Is there any way to check if printer is active in access 2000? I have a report that is printing (local printer), and before I do anything more in code, I do want to check if printer is...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
4
by: JIM.H. | last post by:
Hello, I need to get user name and password from our internet and check Active Directory if the user name is available in the network and password matches, how should I do this and is there a C#...
6
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any...
3
by: Caspy | last post by:
I just get stuck on how to check if a user is a member of network (domain). I am building an internal tracking system with ASP.Net with Form authentication. When an user is added into the system,...
0
by: Sara | last post by:
Dear Sir, I want to access to a special group in active directory but with this function I could just see that a special user is exist in active directory or not, I mean I want to see that a user...
6
by: SamSpade | last post by:
Public Function PicCreateGraphics() As Graphics 'Client should dispose this PicCreateGraphics = Graphics.FromImage(mDocumentImage) mPicCreateGraphicsSaved = PicCreateGraphics 'Saved so I can...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
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 ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.