internal void AddLdapAttribut(LdapAttribut ldapAttribut) { if (ldapAttributs.ContainsKey(ldapAttribut.name)) { ldapAttributs[ldapAttribut.name].AddRange(ldapAttribut.values.ToArray()); } else { ldapAttributs.Add(ldapAttribut.name, ldapAttribut); } }
internal String[] GetTabString(String attributName) { List <String> lstV = new List <string>(); if (ldapAttributs.ContainsKey(attributName)) { LdapAttribut ldapAttribut = ldapAttributs[attributName]; return(ldapAttribut.GetTabString()); } return(null); }
internal String GetJoinString(String attributName) { List <String> lstV = new List <string>(); if (ldapAttributs.ContainsKey(attributName)) { LdapAttribut ldapAttribut = ldapAttributs[attributName]; return(ldapAttribut.GetJoinString()); } return(String.Empty); }
public void AddLdapAttribut(string name, List <string> values) { if (ldapAttributs != null && !ldapAttributs.ContainsKey(name)) { LdapAttribut ldapAttribut = new LdapAttribut(name, values); ldapAttributs.Add(name, ldapAttribut); } else { ldapAttributs[name].Add(values); } }
protected bool IsGroupMember(string dnGroup, string dnUser, string member) { LdapAttribut ldapAttribut = GetAttributs(dnGroup, member); if (ldapAttribut != null) { List <String> lstValues = ldapAttribut.ExistWithValue(dnUser); if (lstValues != null) { return(lstValues.Contains(dnUser, StringComparer.OrdinalIgnoreCase)); } } return(false); }
internal List <string> ExistAttributWithValue(string dn, string attribut, string valeur) { List <string> lstValue = new List <string>(); LdapAttribut ldapAttribut = GetAttributs(dn, attribut); if (ldapAttribut != null) { return(ldapAttribut.ExistWithValue(valeur)); } else { return(null); } }
public void DeleteAttribut(String dn, LdapAttribut ldapAttribut, bool allValues = false) { if (allValues) { DeleteAttribut(dn, ldapAttribut.name); } else { foreach (byte[] b in ldapAttribut.values) { DeleteAttribut(dn, ldapAttribut.name, b); } } }
public void ReplaceAttribut(String dn, LdapAttribut ldapAttribut) { DeleteAttribut(dn, ldapAttribut.name); AddAttribut(dn, ldapAttribut); }
public void AddAttribut(String dn, LdapAttribut ldapAttribut) { AddAttribut(dn, ldapAttribut.name, ldapAttribut.values.ToArray()); }
private List <LdapObj> SearchDn(String baseDn, String ldapFilter, System.DirectoryServices.Protocols.SearchScope scope, String[] attribs) { List <LdapObj> lstLdapObj = null; try { if (!bindingSuccess) { Connect(); } if (attribs != null) { for (int i = 0; i < attribs.Length; i++) { attribs[i] = attribs[i].Trim(); } } SearchRequest request; if (attribs == null) { request = new SearchRequest(baseDn, ldapFilter, scope); } else { request = new SearchRequest(baseDn, ldapFilter, scope, attribs); } SearchResponse result = (SearchResponse)ldapConnexion.SendRequest(request); if ((result != null) && result.Entries.Count > 0) { lstLdapObj = new List <LdapObj>(); foreach (SearchResultEntry sResult in result.Entries) { String dn = sResult.DistinguishedName; LdapObj ldapObj = new LdapObj(dn); if (attribs != null) { foreach (String attr in attribs) { ldapObj.AddLdapAttribut(new LdapAttribut(attr)); } } foreach (DirectoryAttribute attribute in sResult.Attributes.Values) { /*Console.WriteLine(attribute.Name + " ==> " + attribute.Count); * if (attribute.Name.Equals("objectClass")) * Console.WriteLine(attribute.Name + " ==> " + attribute.Count); */ LdapAttribut ldapAttribut = new LdapAttribut(attribute.Name); ldapAttribut.AddRange((byte[][])attribute.GetValues(typeof(byte[]))); ldapObj.AddLdapAttribut(ldapAttribut); } lstLdapObj.Add(ldapObj); } } return(lstLdapObj); } 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; } }