/// <summary> /// Initializes the Entry specific properties e.g entry DN etc. /// </summary> void InitEntry() { LdapUrl lUrl = new LdapUrl(ADsPath); string dn = lUrl.getDN(); if (dn != null) { if (String.Compare(dn, "rootDSE", true) == 0) { InitToRootDse(lUrl.Host, lUrl.Port); } else { DN userDn = new DN(dn); String[] lRdn = userDn.explodeDN(false); _Name = (string)lRdn[0]; _Parent = new DirectoryEntry(conn); _Parent.Path = GetLdapUrlString(lUrl.Host, lUrl.Port, userDn.Parent.ToString()); } } else { _Name = lUrl.Host + ":" + lUrl.Port; _Parent = new DirectoryEntry(conn); _Parent.Path = "Ldap:"; } }
/// <summary> Returns the individual components of a distinguished name (DN). /// /// </summary> /// <param name="dn"> The distinguished name, for example, "cn=Babs /// Jensen,ou=Accounting,o=Acme,c=US" /// /// </param> /// <param name="noTypes"> If true, returns only the values of the /// components and not the names. For example, "Babs /// Jensen", "Accounting", "Acme", "US" instead of /// "cn=Babs Jensen", "ou=Accounting", "o=Acme", and /// "c=US". /// /// </param> /// <returns> An array of strings representing the individual components /// of a DN, or null if the DN is not valid. /// </returns> public static string[] explodeDN(string dn, bool noTypes) { DN dnToExplode = new DN(dn); return(dnToExplode.explodeDN(noTypes)); }