entry.Properties[propName].ToString() == "mobile" isn't evaluating as true
namespace SignatureCreator
{
class Program
{
static void Main(string[] args)
{
string delimiter = ",";
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find currently logged in user
UserPrincipal up = UserPrincipal.Current;
string displayName = up.DisplayName;
string title = up.Description;
string phoneNumber = up.VoiceTelephoneNumber;
string[] userName = displayName.Split(new string[] { delimiter
}, StringSplitOptions.None);
string firstName = userName[1];
string lastName = userName[0];
firstName = firstName.Substring(1);
firstName = firstName.ToUpper();
lastName = lastName.ToUpper();
Console.WriteLine(firstName +" "+ lastName);
Console.WriteLine(title);
Console.WriteLine(phoneNumber);
DirectoryEntry entry = up.GetUnderlyingObject() as
DirectoryEntry;
System.DirectoryServices.PropertyCollection props =
entry.Properties;
/*
*
*/
foreach (string propName in props.PropertyNames)
{
if (entry.Properties[propName].ToString() == "mobile")
{
Console.WriteLine(propName + " = " +
entry.Properties[propName].Value);
}
else
{
Console.WriteLine(propName + " = NULL");
}
}
Console.ReadKey();
StringBuilder sb = new StringBuilder();
}
}
}
I am trying to loop through the active directory info to find the user's
mobile number. But I can't figure out how to loop through this and return
it. Even when I just evaluate the propname == mobile it doesn't return
true. What am I doing wrong?
No comments:
Post a Comment