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;
             }
        }

Any suggestions

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.