2013
03.21

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 ?, 3.5 out of 5 based on 2 ratings

Incoming Search Term

Advertise Here

No Comment

Add Your Comment