public bool ExistDn(string dn) { SearchRequest request; try { Connect2(); DnObj dnObj = DnObj.Parse(dn); request = new SearchRequest(dnObj.BaseDn, dnObj.Filter, SearchScope.Subtree); SearchResponse result = (SearchResponse)ldapConnexion.SendRequest(request); return((result != null) && result.Entries.Count > 0); } catch (LdapException ex) { Console.WriteLine(String.Format("Error LdapException FindPeDateMajCert {0}...", ex.Message)); Console.WriteLine(ex.StackTrace); throw ex; } catch (DirectoryOperationException ex) { Console.WriteLine(String.Format("Error DirectoryOperationException FindPeDateMajCert {0}...", ex.Message)); Console.WriteLine(ex.StackTrace); throw ex; } catch (Exception ex) { Console.WriteLine(String.Format("Error Exception FindPeDateMajCert {0}...", ex.Message)); Console.WriteLine(ex.StackTrace); throw ex; } }
public LdapObj ReadDn(String dn, String[] attribs = null) { DnObj dnObj = DnObj.Parse(dn); List <LdapObj> lstLdapObj = SearchDn(dnObj.BaseDn, dnObj.Filter, SearchScope.OneLevel, attribs); if ((lstLdapObj != null) && lstLdapObj.Count > 0) { return(lstLdapObj[0]); } return(null); }
public List <LdapAttribut> GetAttributs(String dn, String[] attributs) { try { DnObj dnObj = DnObj.Parse(dn); List <LdapObj> lstObj = SearchDn(dnObj.BaseDn, dnObj.Filter, SearchScope.OneLevel, attributs); if (lstObj.Count > 0) { return(lstObj[0].ldapAttributs.Select(e => e.Value).ToList()); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex; } return(null); }