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