I had my code to check the current logged user , it is worked well on local host but when I deployed on server it doesn't work .
private void checkUser()
{
DirectorySearcher searcher = new DirectorySearcher();
searcher.SearchScope = SearchScope.Subtree;
searcher.Filter = string.Format(CultureInfo.InvariantCulture, "(sAMAccountName={0})", Page.User.Identity.Name);
SearchResult findUser = searcher.FindOne();
if (findUser != null)
{
DirectoryEntry user = findUser.GetDirectoryEntry();
string Mobile = user.Properties["Mobile"].Value.ToString();
string Login = user.Properties["sAMAccountName"].Value.ToString();
if (user.Properties["Department"].Value != null)
LoggedDepartement = user.Properties["Department"].Value.ToString();
string title = user.Properties["title"].Value.ToString();
data = user.Properties["thumbnailPhoto"].Value as byte[];
}
}