title: Determine the objectClass of a given id from LDAP
body: <p>What is the best way to get the objectClass name of a give id.</p>
  
  <p>My input should be something like "IDNSKF" 
  My output should be Group or Person or Computer..</p>
  
  <p>I use the following code but however some times in the <code>distinguishedName</code> i don't find <code>OU=Groups</code> although the object is group</p>
  
  <p>Code:</p>
  
  <pre><code>DirectoryEntry de = new DirectoryEntry("LDAP://local.be");
          DirectorySearcher searcher = new DirectorySearcher(de);
          searcher.Filter = "(&amp;(cn=variable))";
          searcher.SearchScope = SearchScope.Subtree;
          searcher.PropertiesToLoad.Add("distinguishedName");
          SearchResult result = searcher.FindOne();
          string s = result.GetDirectoryEntry().Properties["distinguishedName"].Value.ToString();
          if (s.IndexOf("OU=Groups") &gt; -1)
              return Groups;
          if (s.IndexOf("OU=Users") &gt; -1)
              return Users;
          if (s.IndexOf("OU=Computers") &gt; -1)
              return Computer;
  </code></pre>
  
  <p>Thanks</p>