예제 #1
0
파일: DN.cs 프로젝트: VQComms/CsharpLDAP
        /// <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);
        }
예제 #2
0
파일: RDN.cs 프로젝트: VQComms/CsharpLDAP
        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]);

            types    = thisRDN.types;
            values   = thisRDN.values;
            rawValue = thisRDN.rawValue;
            return;
        }
예제 #3
0
파일: DN.cs 프로젝트: VQComms/CsharpLDAP
        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);
        }