Monday, November 06, 2006

How to retrieve the full name of the logged in User

You have to add the reference to System.DirectoryServices to your Project before using it.



Nuno Silva

Application Development Consultant




--------------------------------------------------------------------------------



System.DirectoryServices



Berkay


--------------------------------------------------------------------------------


Hi Berkay Meşe,



Thanks for immediate response to my query.



Can you please let me know the namespace for DirectoryEntry and DirectoryServices?



Note : I am using .Net Framework 1.1 for developing this application .





Regards

Sukesh


--------------------------------------------------------------------------------




string[] sUser;
sUser = Context.User.Identity.Name.ToString().Split(new Char[]{'\\'}, 2);

string Domain_Slash_User = Context.User.Identity.Name;
string Domain_Slash_Machine = Domain_Slash_User.Replace(@"\",@"/");
string queryString = @"WinNT://" + Domain_Slash_Machine;



DirectoryEntry obDirEntry = new DirectoryEntry(queryString);
System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;



object obVal = coll["FullName"].Value;
txtAlias.Text = obVal.ToString();



Berkay Meşe|Technology Solutions Professional|Application Platform
É90(212)-3265441È90(533)-6893610 šberkay.mese@microsoft.com

Try New Cool Features Of Biztalk Server






--------------------------------------------------------------------------------

Hi,



I am using Windows authentication for retrieving the alias and using the following code



private string [] sUser;

sUser = Context.User.Identity.Name.ToString().Split(new Char[]{'\\'}, 2);

txtAlias.Text = sUser[1];



Can anybody help me on how to retrieve the full name of the logged in User?



Regards

Sukesh

No comments: