Sunday, June 29, 2008

Accessing the windows Identity

Add the Namespace
"system.directoryServices;"
"using System.Web.Security;"


Code Logic:
System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent();
string[] a = Context.User.Identity.Name.Split('\\');
System.DirectoryServices.DirectoryEntry ADEntry = new System.DirectoryServices.DirectoryEntry("WinNT://" + a[0] + "/" + a[1]);
string Name = ADEntry.Properties["FullName"].Value.ToString();
Response.Write(" + Name + "");

No comments:

Powered By Blogger