public void initialize() { basedn = null; scope = LdapAPI.LDAPSCOPE.BASE; filter = null; search_attrs = null; attrsonly = false; ldapMsgCallback = null; }
//return an array of ldapPath strings public List <string> FindAllChild(string filter, SearchScope searchScope, string[] propertiesToLoad) { Assign_dirContext(); if (dirContext == null) { return(null); } if (!get_baseDnFor_guidOrsid_called) { Get_baseDn_Guid_Or_sid(); } LdapAPI.LDAPSCOPE ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL; if (searchScope == SearchScope.Base) { ldapscope = LdapAPI.LDAPSCOPE.BASE; } else if (searchScope == SearchScope.OneLevel) { ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL; } else if (searchScope == SearchScope.Subtree) { ldapscope = LdapAPI.LDAPSCOPE.SUB_TREE; } LdapMessage ldapMessage = dirContext.SearchSynchronous( baseDn, ldapscope, filter, //new string[] { "distinguishedName", null }, Getsearch_attrs(propertiesToLoad), false); List <LdapEntry> ldapEntries = (ldapMessage != null ? ldapMessage.Ldap_Get_Entries() : null); if (ldapEntries != null && ldapEntries.Count > 0) { ldapPaths = new List <string>(); foreach (LdapEntry entry in ldapEntries) { Thread thread = new Thread(new ParameterizedThreadStart(GetObjectLdapPath)); thread.Start(entry); thread.Join(); } return(ldapPaths); } return(null); }
//return the found entry's LdapPath public string FindFirstChild(string filter, SearchScope searchScope, string[] propertiesToLoad) { Assign_dirContext(); if (dirContext == null) { return(null); } if (!get_baseDnFor_guidOrsid_called) { Get_baseDn_Guid_Or_sid(); } LdapAPI.LDAPSCOPE ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL; if (searchScope == SearchScope.Base) { ldapscope = LdapAPI.LDAPSCOPE.BASE; } else if (searchScope == SearchScope.OneLevel) { ldapscope = LdapAPI.LDAPSCOPE.ONE_LEVEL; } else if (searchScope == SearchScope.Subtree) { ldapscope = LdapAPI.LDAPSCOPE.SUB_TREE; } LdapMessage ldapMessage = dirContext.SearchSynchronous( baseDn, ldapscope, filter, //new string[] { "distinguishedName", null }, Getsearch_attrs(propertiesToLoad), false); List <LdapEntry> ldapEntries = (ldapMessage != null ? ldapMessage.Ldap_Get_Entries() : null); if (ldapEntries != null && ldapEntries.Count > 0) { LdapEntry entry = ldapEntries[0]; string[] attrsList = entry.GetAttributeNames(); if (attrsList != null && attrsList.Length > 0) { if (entry != null) { LdapValue[] values = entry.GetAttributeValues("distinguishedName", dirContext); if (values != null && values.Length > 0) { return(string.Concat("LDAP://", sServer, "/", values[0].stringData)); } } } else { return(null); } } return(null); }