A quick and simple way to find out who is the current user that access your Intranet application:
private string FindCurrentUser() { var searcher = new DirectorySearcher(); var usr = Request.LogonUserIdentity.Name.IndexOf("\\") > 0 ? Request.LogonUserIdentity.Name.Split("\\".ToCharArray())[1] : Request.LogonUserIdentity.Name; searcher.Filter = "samaccountname=" + usr; var res = searcher.FindOne(); var strName = res == null ? Request.LogonUserIdentity.Name : res.Properties["displayname"][0].ToString(); return strName; }
I hope it helps, cheers!
GD Star Rating
loading...
Who Is Accessing Your Intranet Application ?, loading...
About Hardono
Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.
Incoming Search
active directory, asp.net, c#