I have a rutine that get's the Full user Name from active riectory, it used
to work but now it is not, not sure if some securty update closed something
on AD, Here is my rutine any advice in how to solve it is appreciatted.
public void GetUserName(string strLogin)
{
string str = "";
// Parse the string to check if domain name is present.
int idx = strLogin.IndexOf('\\');
if (idx == -1)
{
idx = strLogin.IndexOf('@');
}
string strDomain;
string strName;
if (idx != -1)
{
strDomain = strLogin.Substring(0, idx);
strName = strLogin.Substring(idx + 1);
}
else
{
strDomain = Environment.MachineName;
strName = strLogin;
}
DirectoryEntry obDirEntry = null;
try
{
obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" +
strName);
System.DirectoryServices.PropertyCollection coll =
obDirEntry.Properties;
object obFullName = coll["FullName"].Value;
FullName = obFullName.ToString();
}
catch (Exception ex)
{
str = "" + ex.ToString();
}
}
|