0

As you know I am new to C# and am having trouble with some code that I am writing, thats why im posting here to get knowledge from you guys:)


Well, i have a text box in which i will enter the usersID of the user
(the userID is in the attribute tab of the users properties in active directory)

and when i click the button i want it to check if the user exsists or not, and print few informatiom about the user if exists.

how can i do this?

what i did is how to get the users data:

protected void Page_Load(object sender, EventArgs e)
    {
        String Name = "Lucy";
            DirectoryEntry entry = new DirectoryEntry("//DomainName");
             DirectorySearcher dsearch = new DirectorySearcher(entry);
        dsearch.Filter = "(&(objectClass=user)(l=" + Name + "))";

        foreach (SearchResult sResultSet in dsearch.FindAll())
        {

                      Console.WriteLine(GetProperty(sResultSet, "employeeID"));
        }


    }
    protected static string GetProperty(SearchResult searchResult,  string PropertyName)
      {
           if(searchResult.Properties.Contains(PropertyName))
             {
                 return searchResult.Properties[PropertyName][0].ToString() ;
             }
           else
            {
                  return string.Empty;
             }
        }
1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by nmohammed
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.