/// <summary> /// Searches Active Directory for objects specified by the given Path + filter, included in the AD_SearchObjectProperties class. /// </summary> /// <param name="ldapConnectionInfo">The LDAP connection information</param> /// <param name="SearchParameters">Path, filter and returned properties needed for the query</param> /// <returns>LdapResult class: the Collection of the SearchEntry classes.</returns> public static List <OutputSearchEntry> AD_SearchObjects([PropertyTab] LdapConnectionInfo ldapConnectionInfo, [PropertyTab] AD_SearchObjectProperties SearchParameters) { var ldapQueryInfo = new LdapConnectionInfo { LdapUri = ldapConnectionInfo.LdapUri + "/" + SearchParameters.Path, Username = ldapConnectionInfo.Username, Password = ldapConnectionInfo.Password }; List <SearchResult> tmpObjectEntries; // Search objects. using (var ldap = new LdapService(ldapQueryInfo)) tmpObjectEntries = ldap.SearchObjectsByFilterSpecifyProperties(SearchParameters.Filter, SearchParameters.PropertiesToLoad, SearchParameters.PageSize); // Create & return result list. var retOutputs = new List <OutputSearchEntry>(); foreach (var item in tmpObjectEntries) { var outputClass = new OutputSearchEntry { SearchEntry = item }; retOutputs.Add(outputClass); } return(retOutputs); }