A DN encapsulates a Distinguished Name (an ldap name with context). A DN does not need to be fully distinguished, or extend to the Root of a directory. It provides methods to get information about the DN and to manipulate the DN. The following are examples of valid DN:
  • cn=admin,ou=marketing,o=corporation
  • cn=admin,ou=marketing
  • 2.5.4.3=admin,ou=marketing
  • oid.2.5.4.3=admin,ou=marketing
Note: Multivalued attributes are all considered to be one component and are represented in one RDN (see RDN)
상속: System.Object
		/// <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:";
			}
		}
예제 #2
0
        /// <summary>Determines if this DN is <I>contained</I> by the DN passed in.  For
        /// example:  "cn=admin, ou=marketing, o=corporation" is contained by
        /// "o=corporation", "ou=marketing, o=corporation", and "ou=marketing"
        /// but <B>not</B> by "cn=admin" or "cn=admin,ou=marketing,o=corporation"
        /// Note: For users of Netscape's SDK this method is comparable to contains
        ///
        /// </summary>
        /// <param name="containerDN">of a container
        /// </param>
        /// <returns> true if containerDN contains this DN
        /// </returns>
        public virtual bool isDescendantOf(DN containerDN)
        {
            int i = containerDN.rdnList.Count - 1; //index to an RDN of the ContainerDN
            int j = rdnList.Count - 1;             //index to an RDN of the ContainedDN

            //Search from the end of the DN for an RDN that matches the end RDN of
            //containerDN.
            while (!((RDN)rdnList[j]).equals((RDN)containerDN.rdnList[i]))
            {
                j--;
                if (j <= 0)
                {
                    return(false);
                }
                //if the end RDN of containerDN does not have any equal
                //RDN in rdnList, then containerDN does not contain this DN
            }
            i--; //avoid a redundant compare
            j--;
            //step backwards to verify that all RDNs in containerDN exist in this DN
            for (; i >= 0 && j >= 0; i--, j--)
            {
                if (!((RDN)rdnList[j]).equals((RDN)containerDN.rdnList[i]))
                {
                    return(false);
                }
            }
            if (j == 0 && i == 0)
            {
                //the DNs are identical and thus not contained
                return(false);
            }

            return(true);
        }
예제 #3
0
        private System.Collections.ArrayList values; //list of Value strings

        #endregion Fields

        #region Constructors

        /// <summary> Creates an RDN object from the DN component specified in the string RDN
        /// 
        /// </summary>
        /// <param name="rdn">the DN component
        /// </param>
        public RDN(System.String rdn)
        {
            rawValue = rdn;
            DN dn = new DN(rdn);
            System.Collections.ArrayList rdns = dn.RDNs;
            //there should only be one rdn
            if (rdns.Count != 1)
                throw new System.ArgumentException("Invalid RDN: see API " + "documentation");
            RDN thisRDN = (RDN) (rdns[0]);
            this.types = thisRDN.types;
            this.values = thisRDN.values;
            this.rawValue = thisRDN.rawValue;
            return ;
        }
예제 #4
0
        private string rawValue;  //the unnormalized value

        /// <summary> Creates an RDN object from the DN component specified in the string RDN
        ///
        /// </summary>
        /// <param name="rdn">the DN component
        /// </param>
        public RDN(string rdn)
        {
            rawValue = rdn;
            DN        dn   = new DN(rdn);
            ArrayList rdns = dn.RDNs;

            //there should only be one rdn
            if (rdns.Count != 1)
            {
                throw new ArgumentException("Invalid RDN: see API " + "documentation");
            }
            RDN thisRDN = (RDN)(rdns[0]);

            this.types    = thisRDN.types;
            this.values   = thisRDN.values;
            this.rawValue = thisRDN.rawValue;
        }
예제 #5
0
        private string rawValue;           //the unnormalized value

        /// <summary>
        ///     Creates an RDN object from the DN component specified in the string RDN
        /// </summary>
        /// <param name="rdn">
        ///     the DN component
        /// </param>
        public RDN(string rdn)
        {
            rawValue = rdn;
            var dn   = new DN(rdn);
            var rdns = dn.RDNs;

            //there should only be one rdn
            if (rdns.Count != 1)
            {
                throw new ArgumentException("Invalid RDN: see API " + "documentation");
            }
            var thisRDN = (RDN)rdns[0];

            types    = thisRDN.types;
            values   = thisRDN.values;
            rawValue = thisRDN.rawValue;
        }
예제 #6
0
        public bool Equals(DN toDN)
        {
            ArrayList aList  = toDN.getrdnList();
            int       length = aList.Count;

            if (rdnList.Count != length)
            {
                return(false);
            }

            for (int i = 0; i < length; i++)
            {
                if (!((RDN)rdnList[i]).equals((RDN)toDN.getrdnList()[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #7
0
파일: LdapDN.cs 프로젝트: nickchal/pash
		public static bool equals(System.String dn1, System.String dn2)
		{
			DN dnA = new DN(dn1);
			DN dnB = new DN(dn2);
			return dnA.Equals(dnB);
		}
예제 #8
0
파일: LdapDN.cs 프로젝트: nickchal/pash
		/// <summary> Returns the DN normalized by removal of non-significant space characters
		/// as per RFC 2253, section4.
		/// 
		/// </summary>
		/// <returns>      a normalized string
		/// </returns>
		public static System.String normalize(System.String dn)
		{
			DN testDN = new DN(dn);
			return testDN.ToString();
		}
예제 #9
0
파일: LdapDN.cs 프로젝트: nickchal/pash
		/// <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 System.String[] explodeDN(System.String dn, bool noTypes)
		{
			DN dnToExplode = new DN(dn);
			return dnToExplode.explodeDN(noTypes);
		}
예제 #10
0
파일: LdapTreeView.cs 프로젝트: MrJoe/lat
        void AddEntry(string name, Connection conn, TreeIter iter)
        {
            try {

                Pixbuf pb = Pixbuf.LoadFromResource ("x-directory-normal.png");
             		LdapEntry[] ldapEntries = conn.Data.GetEntryChildren (name);

                foreach (LdapEntry le in ldapEntries) {

                    Log.Debug ("\tchild: {0}", le.DN);
                    DN dn = new DN (le.DN);
                    RDN rdn = (RDN) dn.RDNs[0];

                    TreeIter newChild;

                    newChild = browserStore.AppendValues (iter, pb, le.DN, rdn.Value);
                    browserStore.AppendValues (newChild, pb, "", "");
                }

            } catch {

                string	msg = Mono.Unix.Catalog.GetString (
                    "Unable to read data from server");

                HIGMessageDialog dialog = new HIGMessageDialog (
                    parent,
                    0,
                    Gtk.MessageType.Error,
                    Gtk.ButtonsType.Ok,
                    "Network error",
                    msg);

                dialog.Run ();
                dialog.Destroy ();
            }
        }
		/// <summary>
		/// Initializes the Entry specific properties e.g entry DN etc.
		/// </summary>
		void InitEntry()
		{
			LdapUrl lUrl=new LdapUrl (Path);
			if(lUrl.getDN()!=null)			{
				DN userDn = new DN(lUrl.getDN());
				String[] lRdn = userDn.explodeDN(false);
				_Name = (string)lRdn[0];
				_Parent = new DirectoryEntry(conn);
				LdapUrl cUrl=new LdapUrl(lUrl.Host,lUrl.Port,userDn.Parent.ToString());
				_Parent.Path=cUrl.ToString();
			}
			else			{
				_Name=lUrl.Host+":"+lUrl.Port;
				_Parent = new DirectoryEntry(conn);
				_Parent.Path = "Ldap:";
			}
		}
예제 #12
0
        /// <summary>Determines if this DN is <I>contained</I> by the DN passed in.  For
        /// example:  "cn=admin, ou=marketing, o=corporation" is contained by
        /// "o=corporation", "ou=marketing, o=corporation", and "ou=marketing"
        /// but <B>not</B> by "cn=admin" or "cn=admin,ou=marketing,o=corporation"
        /// Note: For users of Netscape's SDK this method is comparable to contains
        /// 
        /// </summary>
        /// <param name="containerDN">of a container
        /// </param>
        /// <returns> true if containerDN contains this DN
        /// </returns>
        public virtual bool isDescendantOf(DN containerDN)
        {
            int i = containerDN.rdnList.Count - 1; //index to an RDN of the ContainerDN
            int j = this.rdnList.Count - 1; //index to an RDN of the ContainedDN
            //Search from the end of the DN for an RDN that matches the end RDN of
            //containerDN.
            while (!((RDN) this.rdnList[j]).equals((RDN) containerDN.rdnList[i]))
            {
                j--;
                if (j <= 0)
                    return false;
                //if the end RDN of containerDN does not have any equal
                //RDN in rdnList, then containerDN does not contain this DN
            }
            i--; //avoid a redundant compare
            j--;
            //step backwards to verify that all RDNs in containerDN exist in this DN
            for (; i >= 0 && j >= 0; i--, j--)
            {
                if (!((RDN) this.rdnList[j]).equals((RDN) containerDN.rdnList[i]))
                    return false;
            }
            if (j == 0 && i == 0)
            //the DNs are identical and thus not contained
                return false;

            return true;
        }
예제 #13
0
        public bool Equals(DN toDN)
        {
            System.Collections.ArrayList aList=toDN.getrdnList();
            int length = aList.Count;

            if (this.rdnList.Count != length)
                return false;

            for (int i = 0; i < length; i++)
            {
                if (!((RDN) rdnList[i]).equals((RDN) toDN.getrdnList()[i]))
                    return false;
            }
            return true;
        }