I have this function below:
public string GetADDisplayName(string strLogin)
{
int length = strLogin.IndexOf('\\');
if (length == -1)
length = strLogin.IndexOf('@');
string str1;
string str2;
if (length != -1)
{
str1 = strLogin.Substring(0, length);
str2 = strLogin.Substring(length + 1);
}
else
{
str1 = Environment.MachineName;
str2 = strLogin;
}
string str3;
try
{
str3 = new DirectoryEntry("WinNT://" + str1 + "/" + str2).Properties["FullName"].Value.ToString();
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "alert('GetADDisplayName ERROR: " + ex.ToString() + "');", true);
str3 = "";
}
return str3;
}
The value I pass into the function is HttpContext.Current.User.Identity.Name.Trim()
.
When I debug/F5 in my visual studio, it show me the FullName.
When I deploy to web server and access it from within the web server itself, it show me the FullName.
But when I access the web server from client, it failed to show me the FullName, why is that?