title: User Name is not fetching after Hosting in IIS :: LDAP C# but working fine in local host
body: <p>below is my code to fetch the username.</p>
  
  <pre><code>string user = Request.LogonUserIdentity.Name;
              user = user.Substring(user.Length - 7, 7);
             // lblusername.Text = user;
  
              DirectorySearcher dssearch = new DirectorySearcher();
              dssearch.Filter = "(sAMAccountName=" + user + ")";
              SearchResult sresult = dssearch.FindOne();
  
              if (sresult != null)
              {
                   DirectoryEntry dsresult = new DirectoryEntry("LDAP://DC=somename,DC=com");
                   dsresult = sresult.GetDirectoryEntry();
  
                   lblusername.Text = dsresult.Properties["displayName"][0].ToString();
  
              }
  </code></pre>
  
  <p>IIS is having Windows Authentication Mode.
  also defined in web confiq</p>