예제 #1
0
 internal DirectoryResponse(XmlNode node)
 {
     this.result      = ResultCode.OperationsError | ResultCode.ProtocolError | ResultCode.TimeLimitExceeded | ResultCode.SizeLimitExceeded | ResultCode.CompareFalse | ResultCode.CompareTrue | ResultCode.AuthMethodNotSupported | ResultCode.StrongAuthRequired | ResultCode.ReferralV2 | ResultCode.Referral | ResultCode.AdminLimitExceeded | ResultCode.UnavailableCriticalExtension | ResultCode.ConfidentialityRequired | ResultCode.SaslBindInProgress | ResultCode.NoSuchAttribute | ResultCode.UndefinedAttributeType | ResultCode.InappropriateMatching | ResultCode.ConstraintViolation | ResultCode.AttributeOrValueExists | ResultCode.InvalidAttributeSyntax | ResultCode.NoSuchObject | ResultCode.AliasProblem | ResultCode.InvalidDNSyntax | ResultCode.AliasDereferencingProblem | ResultCode.InappropriateAuthentication | ResultCode.InsufficientAccessRights | ResultCode.Busy | ResultCode.Unavailable | ResultCode.UnwillingToPerform | ResultCode.LoopDetect | ResultCode.SortControlMissing | ResultCode.OffsetRangeError | ResultCode.NamingViolation | ResultCode.ObjectClassViolation | ResultCode.NotAllowedOnNonLeaf | ResultCode.NotAllowedOnRdn | ResultCode.EntryAlreadyExists | ResultCode.ObjectClassModificationsProhibited | ResultCode.ResultsTooLarge | ResultCode.AffectsMultipleDsas | ResultCode.VirtualListViewError | ResultCode.Other;
     this.dsmlNode    = node;
     this.dsmlNS      = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlRequest = true;
 }
예제 #2
0
 internal DirectoryResponse(XmlNode node)
 {
     this.result      = ~System.DirectoryServices.Protocols.ResultCode.Success;
     this.dsmlNode    = node;
     this.dsmlNS      = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlRequest = true;
 }
예제 #3
0
 internal SearchResultEntry(XmlNode node)
 {
     this.attributes  = new SearchResultAttributeCollection();
     this.dsmlNode    = node;
     this.dsmlNS      = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlRequest = true;
 }
예제 #4
0
 internal DsmlResponseDocument(StringBuilder responseString, string xpathToResponse) : this()
 {
     this.dsmlDocument = new XmlDocument();
     try
     {
         this.dsmlDocument.LoadXml(responseString.ToString());
     }
     catch (XmlException xmlException)
     {
         throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
     }
     this.dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlBatchResponse = (XmlElement)this.dsmlDocument.SelectSingleNode(xpathToResponse, this.dsmlNS);
     if (this.dsmlBatchResponse != null)
     {
         XmlNodeList childNodes = this.dsmlBatchResponse.ChildNodes;
         foreach (XmlNode childNode in childNodes)
         {
             if (childNode.NodeType != XmlNodeType.Element)
             {
                 continue;
             }
             DirectoryResponse directoryResponse = this.ConstructElement((XmlElement)childNode);
             this.dsmlResponse.Add(directoryResponse);
         }
         return;
     }
     else
     {
         throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
     }
 }
예제 #5
0
        private string ExtractSessionID(HttpWebResponse resp)
        {
            string       value;
            Stream       responseStream = resp.GetResponseStream();
            StreamReader streamReader   = new StreamReader(responseStream);

            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                try
                {
                    xmlDocument.Load(streamReader);
                }
                catch (XmlException xmlException)
                {
                    throw new DsmlInvalidDocumentException();
                }
                XmlNamespaceManager dsmlNamespaceManager = NamespaceUtils.GetDsmlNamespaceManager();
                XmlAttribute        xmlAttribute         = (XmlAttribute)xmlDocument.SelectSingleNode("se:Envelope/se:Header/ad:Session/@ad:SessionID", dsmlNamespaceManager);
                if (xmlAttribute == null)
                {
                    xmlAttribute = (XmlAttribute)xmlDocument.SelectSingleNode("se:Envelope/se:Header/ad:Session/@SessionID", dsmlNamespaceManager);
                    if (xmlAttribute == null)
                    {
                        throw new DsmlInvalidDocumentException(Res.GetString("NoSessionIDReturned"));
                    }
                }
                value = xmlAttribute.Value;
            }
            finally
            {
                streamReader.Close();
            }
            return(value);
        }
        private string ExtractSessionID(HttpWebResponse resp)
        {
            string       str;
            StreamReader txtReader = new StreamReader(resp.GetResponseStream());

            try
            {
                XmlDocument document = new XmlDocument();
                try
                {
                    document.Load(txtReader);
                }
                catch (XmlException)
                {
                    throw new DsmlInvalidDocumentException();
                }
                XmlNamespaceManager dsmlNamespaceManager = NamespaceUtils.GetDsmlNamespaceManager();
                XmlAttribute        attribute            = (XmlAttribute)document.SelectSingleNode("se:Envelope/se:Header/ad:Session/@ad:SessionID", dsmlNamespaceManager);
                if (attribute == null)
                {
                    attribute = (XmlAttribute)document.SelectSingleNode("se:Envelope/se:Header/ad:Session/@SessionID", dsmlNamespaceManager);
                    if (attribute == null)
                    {
                        throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("NoSessionIDReturned"));
                    }
                }
                str = attribute.Value;
            }
            finally
            {
                txtReader.Close();
            }
            return(str);
        }
예제 #7
0
 internal DsmlResponseDocument(StringBuilder responseString, string xpathToResponse) : this()
 {
     this.dsmlDocument = new XmlDocument();
     try
     {
         this.dsmlDocument.LoadXml(responseString.ToString());
     }
     catch (XmlException)
     {
         throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("NotWellFormedResponse"));
     }
     this.dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlBatchResponse = (XmlElement)this.dsmlDocument.SelectSingleNode(xpathToResponse, this.dsmlNS);
     if (this.dsmlBatchResponse == null)
     {
         throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("NotWellFormedResponse"));
     }
     foreach (XmlNode node in this.dsmlBatchResponse.ChildNodes)
     {
         if (node.NodeType == XmlNodeType.Element)
         {
             DirectoryResponse response = this.ConstructElement((XmlElement)node);
             this.dsmlResponse.Add(response);
         }
     }
 }
        internal DirectoryControl(XmlElement el)
        {
            XmlAttribute attribute2;

            this.directoryControlType        = "";
            this.directoryControlCriticality = true;
            this.directoryControlServerSide  = true;
            XmlNamespaceManager dsmlNamespaceManager = NamespaceUtils.GetDsmlNamespaceManager();
            XmlAttribute        attribute            = (XmlAttribute)el.SelectSingleNode("@dsml:criticality", dsmlNamespaceManager);

            if (attribute == null)
            {
                attribute = (XmlAttribute)el.SelectSingleNode("@criticality", dsmlNamespaceManager);
            }
            if (attribute == null)
            {
                this.directoryControlCriticality = false;
            }
            else
            {
                string str = attribute.Value;
                switch (str)
                {
                case "true":
                case "1":
                    this.directoryControlCriticality = true;
                    goto Label_00B5;
                }
                if (!(str == "false") && !(str == "0"))
                {
                    throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("BadControl"));
                }
                this.directoryControlCriticality = false;
            }
Label_00B5:
            attribute2 = (XmlAttribute)el.SelectSingleNode("@dsml:type", dsmlNamespaceManager);
            if (attribute2 == null)
            {
                attribute2 = (XmlAttribute)el.SelectSingleNode("@type", dsmlNamespaceManager);
            }
            if (attribute2 == null)
            {
                throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("BadControl"));
            }
            this.directoryControlType = attribute2.Value;
            XmlElement element = (XmlElement)el.SelectSingleNode("dsml:controlValue", dsmlNamespaceManager);

            if (element != null)
            {
                try
                {
                    this.directoryControlValue = Convert.FromBase64String(element.InnerText);
                }
                catch (FormatException)
                {
                    throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("BadControl"));
                }
            }
        }
예제 #9
0
        internal DirectoryAttribute(XmlElement node)
        {
            this.attributeName = "";
            string xpath = "@dsml:name";
            string str2  = "@name";
            XmlNamespaceManager dsmlNamespaceManager = NamespaceUtils.GetDsmlNamespaceManager();
            XmlAttribute        attribute            = (XmlAttribute)node.SelectSingleNode(xpath, dsmlNamespaceManager);

            if (attribute == null)
            {
                attribute = (XmlAttribute)node.SelectSingleNode(str2, dsmlNamespaceManager);
                if (attribute == null)
                {
                    throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("MissingSearchResultEntryAttributeName"));
                }
                this.attributeName = attribute.Value;
            }
            else
            {
                this.attributeName = attribute.Value;
            }
            XmlNodeList list = node.SelectNodes("dsml:value", dsmlNamespaceManager);

            if (list.Count != 0)
            {
                foreach (XmlNode node2 in list)
                {
                    XmlAttribute attribute2 = (XmlAttribute)node2.SelectSingleNode("@xsi:type", dsmlNamespaceManager);
                    if (attribute2 == null)
                    {
                        this.Add(node2.InnerText);
                    }
                    else if (string.Compare(attribute2.Value, "xsd:string", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        this.Add(node2.InnerText);
                    }
                    else if (string.Compare(attribute2.Value, "xsd:base64Binary", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        byte[] buffer;
                        string innerText = node2.InnerText;
                        try
                        {
                            buffer = Convert.FromBase64String(innerText);
                        }
                        catch (FormatException)
                        {
                            throw new DsmlInvalidDocumentException(System.DirectoryServices.Protocols.Res.GetString("BadBase64Value"));
                        }
                        this.Add(buffer);
                    }
                    else if (string.Compare(attribute2.Value, "xsd:anyURI", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Uri uri = new Uri(node2.InnerText);
                        this.Add(uri);
                    }
                }
            }
        }
예제 #10
0
        internal DsmlResponseDocument(HttpWebResponse resp, string xpathToResponse) : this()
        {
            // Our caller (the DsmlConnection-derived class) passes us the XPath telling us
            // how to locate the batchResponse element.  This permits us to work with
            // different transport protocols.

            // Get the response stream
            Stream       respStream       = resp.GetResponseStream();
            StreamReader respStreamReader = new StreamReader(respStream);

            try
            {
                // Load the response from the stream into the XmlDocument
                _dsmlDocument = new XmlDocument();

                try
                {
                    _dsmlDocument.Load(respStreamReader);
                }
                catch (XmlException)
                {
                    // The server didn't return well-formed XML to us
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
                }

                // Locate the batchResponse element within the response document
                _dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
                _dsmlBatchResponse = (XmlElement)_dsmlDocument.SelectSingleNode(xpathToResponse, _dsmlNS);

                if (_dsmlBatchResponse == null)
                {
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
                }

                // parse the response and put it in our internal store
                XmlNodeList nodeList = _dsmlBatchResponse.ChildNodes;

                // Unfortunately, we can't just index into the XmlNodeList,
                // because it's a list of all the nodes, not just the elements.
                // We're interested in the Nth element, not the Nth node.

                foreach (XmlNode node in nodeList)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        Debug.Assert(node is XmlElement);

                        DirectoryResponse el = ConstructElement((XmlElement)node);
                        _dsmlResponse.Add(el);
                    }
                }
            }
            finally
            {
                respStreamReader.Close();
            }
        }
예제 #11
0
        internal DirectoryResponse(XmlNode node)
        {
            Debug.Assert(node != null);

            dsmlNode = node;

            dsmlNS = NamespaceUtils.GetDsmlNamespaceManager();

            dsmlRequest = true;
        }
예제 #12
0
        internal SearchResultReference(XmlNode node)
        {
            Debug.Assert(node != null);

            _dsmlNode = node;

            _dsmlNS = NamespaceUtils.GetDsmlNamespaceManager();

            _dsmlRequest = true;
        }
예제 #13
0
        /// <summary>
        /// This method extracts the sessionID value from the Session header
        /// of a response
        /// </summary>
        private string ExtractSessionID(HttpWebResponse resp)
        {
            // Transform the response into an XmlDocument
            Stream       respStream = resp.GetResponseStream();
            StreamReader respReader = new StreamReader(respStream);

            try
            {
                XmlDocument respXml = new XmlDocument();

                try
                {
                    respXml.Load(respReader);
                }
                catch (XmlException)
                {
                    // The server didn't return well-formed XML to us
                    throw new DsmlInvalidDocumentException();
                }

                // Locate the SessionID attribute node
                XmlNamespaceManager ns   = NamespaceUtils.GetDsmlNamespaceManager();
                XmlAttribute        node = (XmlAttribute)respXml.SelectSingleNode("se:Envelope/se:Header/ad:Session/@ad:SessionID", ns);

                if (node == null)
                {
                    // try it without the namespace qualifier on the attribute, since default namespaces don't
                    // apply to attributes
                    node = (XmlAttribute)respXml.SelectSingleNode("se:Envelope/se:Header/ad:Session/@SessionID", ns);

                    if (node == null)
                    {
                        throw new DsmlInvalidDocumentException(Res.GetString(Res.NoSessionIDReturned));
                    }
                }

                return(node.Value);
            }
            finally
            {
                respReader.Close();
            }
        }
예제 #14
0
        internal DsmlResponseDocument(StringBuilder responseString, string xpathToResponse) : this()
        {
            _dsmlDocument = new XmlDocument();

            try
            {
                _dsmlDocument.LoadXml(responseString.ToString());
            }
            catch (XmlException)
            {
                // The server didn't return well-formed XML to us
                throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
            }

            // Locate the batchResponse element within the response document
            _dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
            _dsmlBatchResponse = (XmlElement)_dsmlDocument.SelectSingleNode(xpathToResponse, _dsmlNS);

            if (_dsmlBatchResponse == null)
            {
                throw new DsmlInvalidDocumentException(Res.GetString(Res.NotWellFormedResponse));
            }

            // parse the response and put it in our internal store
            XmlNodeList nodeList = _dsmlBatchResponse.ChildNodes;

            // Unfortunately, we can't just index into the XmlNodeList,
            // because it's a list of all the nodes, not just the elements.
            // We're interested in the Nth element, not the Nth node.

            foreach (XmlNode node in nodeList)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    Debug.Assert(node is XmlElement);

                    DirectoryResponse el = ConstructElement((XmlElement)node);
                    _dsmlResponse.Add(el);
                }
            }
        }
예제 #15
0
        internal DsmlResponseDocument(HttpWebResponse resp, string xpathToResponse) : this()
        {
            Stream       responseStream = resp.GetResponseStream();
            StreamReader streamReader   = new StreamReader(responseStream);

            try
            {
                this.dsmlDocument = new XmlDocument();
                try
                {
                    this.dsmlDocument.Load(streamReader);
                }
                catch (XmlException xmlException)
                {
                    throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
                }
                this.dsmlNS            = NamespaceUtils.GetDsmlNamespaceManager();
                this.dsmlBatchResponse = (XmlElement)this.dsmlDocument.SelectSingleNode(xpathToResponse, this.dsmlNS);
                if (this.dsmlBatchResponse != null)
                {
                    XmlNodeList childNodes = this.dsmlBatchResponse.ChildNodes;
                    foreach (XmlNode childNode in childNodes)
                    {
                        if (childNode.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }
                        DirectoryResponse directoryResponse = this.ConstructElement((XmlElement)childNode);
                        this.dsmlResponse.Add(directoryResponse);
                    }
                }
                else
                {
                    throw new DsmlInvalidDocumentException(Res.GetString("NotWellFormedResponse"));
                }
            }
            finally
            {
                streamReader.Close();
            }
        }
예제 #16
0
        internal DirectoryControl(XmlElement el)
        {
            XmlNamespaceManager ns = NamespaceUtils.GetDsmlNamespaceManager();

            //
            // Populate the control's criticality
            //
            XmlAttribute attrCriticality = (XmlAttribute)el.SelectSingleNode("@dsml:criticality", ns);

            if (attrCriticality == null)
            {
                // try it without the namespace qualifier, in case the sender omitted it
                attrCriticality = (XmlAttribute)el.SelectSingleNode("@criticality", ns);
            }

            if (attrCriticality == null)
            {
                // DSML v2 defaults criticality to false if not present in the XML
                _directoryControlCriticality = false;
            }
            else
            {
                string s = attrCriticality.Value;

                if ((s == "true") ||
                    (s == "1"))
                {
                    _directoryControlCriticality = true;
                }
                else if ((s == "false") ||
                    (s == "0"))
                {
                    _directoryControlCriticality = false;
                }
                else
                {
                    Debug.WriteLine("Processing response, the control has wrong value of crticality specified");
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.BadControl));
                }
            }

            //
            // Populate the control's name (Type)
            //
            XmlAttribute attrType = (XmlAttribute)el.SelectSingleNode("@dsml:type", ns);

            if (attrType == null)
            {
                // try it without the namespace qualifier, in case the sender omitted it
                attrType = (XmlAttribute)el.SelectSingleNode("@type", ns);
            }

            if (attrType == null)
            {
                // DSML v2 requires the control to specify a type
                Debug.WriteLine("Processing response, the control does not have oid defined");
                throw new DsmlInvalidDocumentException(Res.GetString(Res.BadControl));
            }
            else
            {
                _directoryControlType = attrType.Value;
            }

            //
            // Populate the control's value
            //
            XmlElement elemValue = (XmlElement)el.SelectSingleNode("dsml:controlValue", ns);

            if (elemValue != null)
            {
                try
                {
                    this.directoryControlValue = System.Convert.FromBase64String(elemValue.InnerText);
                }
                catch (FormatException)
                {
                    Debug.WriteLine("Processing response, converting control value failed");
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.BadControl));
                }
            }
        }
예제 #17
0
        internal DirectoryAttribute(XmlElement node)
        {
            byte[] numArray;
            this.attributeName = "";
            string str  = "@dsml:name";
            string str1 = "@name";
            XmlNamespaceManager dsmlNamespaceManager = NamespaceUtils.GetDsmlNamespaceManager();
            XmlAttribute        xmlAttribute         = (XmlAttribute)node.SelectSingleNode(str, dsmlNamespaceManager);

            if (xmlAttribute != null)
            {
                this.attributeName = xmlAttribute.Value;
            }
            else
            {
                xmlAttribute = (XmlAttribute)node.SelectSingleNode(str1, dsmlNamespaceManager);
                if (xmlAttribute != null)
                {
                    this.attributeName = xmlAttribute.Value;
                }
                else
                {
                    throw new DsmlInvalidDocumentException(Res.GetString("MissingSearchResultEntryAttributeName"));
                }
            }
            XmlNodeList xmlNodeLists = node.SelectNodes("dsml:value", dsmlNamespaceManager);

            if (xmlNodeLists.Count != 0)
            {
                foreach (XmlNode xmlNodes in xmlNodeLists)
                {
                    XmlAttribute xmlAttribute1 = (XmlAttribute)xmlNodes.SelectSingleNode("@xsi:type", dsmlNamespaceManager);
                    if (xmlAttribute1 != null)
                    {
                        if (string.Compare(xmlAttribute1.Value, "xsd:string", StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            if (string.Compare(xmlAttribute1.Value, "xsd:base64Binary", StringComparison.OrdinalIgnoreCase) != 0)
                            {
                                if (string.Compare(xmlAttribute1.Value, "xsd:anyURI", StringComparison.OrdinalIgnoreCase) != 0)
                                {
                                    continue;
                                }
                                Uri uri = new Uri(xmlNodes.InnerText);
                                this.Add(uri);
                            }
                            else
                            {
                                string innerText = xmlNodes.InnerText;
                                try
                                {
                                    numArray = Convert.FromBase64String(innerText);
                                }
                                catch (FormatException formatException)
                                {
                                    throw new DsmlInvalidDocumentException(Res.GetString("BadBase64Value"));
                                }
                                this.Add(numArray);
                            }
                        }
                        else
                        {
                            this.Add(xmlNodes.InnerText);
                        }
                    }
                    else
                    {
                        this.Add(xmlNodes.InnerText);
                    }
                }
            }
        }
예제 #18
0
 internal SearchResultReference(XmlNode node)
 {
     this.dsmlNode    = node;
     this.dsmlNS      = NamespaceUtils.GetDsmlNamespaceManager();
     this.dsmlRequest = true;
 }
예제 #19
0
        internal DirectoryControl(XmlElement el)
        {
            this.directoryControlType        = "";
            this.directoryControlCriticality = true;
            this.directoryControlServerSide  = true;
            XmlNamespaceManager dsmlNamespaceManager = NamespaceUtils.GetDsmlNamespaceManager();
            XmlAttribute        xmlAttribute         = (XmlAttribute)el.SelectSingleNode("@dsml:criticality", dsmlNamespaceManager);

            if (xmlAttribute == null)
            {
                xmlAttribute = (XmlAttribute)el.SelectSingleNode("@criticality", dsmlNamespaceManager);
            }
            if (xmlAttribute != null)
            {
                string value = xmlAttribute.Value;
                if (value == "true" || value == "1")
                {
                    this.directoryControlCriticality = true;
                }
                else
                {
                    if (value == "false" || value == "0")
                    {
                        this.directoryControlCriticality = false;
                    }
                    else
                    {
                        throw new DsmlInvalidDocumentException(Res.GetString("BadControl"));
                    }
                }
            }
            else
            {
                this.directoryControlCriticality = false;
            }
            XmlAttribute xmlAttribute1 = (XmlAttribute)el.SelectSingleNode("@dsml:type", dsmlNamespaceManager);

            if (xmlAttribute1 == null)
            {
                xmlAttribute1 = (XmlAttribute)el.SelectSingleNode("@type", dsmlNamespaceManager);
            }
            if (xmlAttribute1 != null)
            {
                this.directoryControlType = xmlAttribute1.Value;
                XmlElement xmlElement = (XmlElement)el.SelectSingleNode("dsml:controlValue", dsmlNamespaceManager);
                if (xmlElement != null)
                {
                    try
                    {
                        this.directoryControlValue = Convert.FromBase64String(xmlElement.InnerText);
                    }
                    catch (FormatException formatException)
                    {
                        throw new DsmlInvalidDocumentException(Res.GetString("BadControl"));
                    }
                }
                return;
            }
            else
            {
                throw new DsmlInvalidDocumentException(Res.GetString("BadControl"));
            }
        }
예제 #20
0
        internal DirectoryAttribute(XmlElement node)
        {
            // retrieve attribute name
            string primaryXPath        = "@dsml:name";
            string secondaryXPath      = "@name";
            XmlNamespaceManager dsmlNS = NamespaceUtils.GetDsmlNamespaceManager();

            XmlAttribute attrName = (XmlAttribute)node.SelectSingleNode(primaryXPath, dsmlNS);

            if (attrName == null)
            {
                // try it without the namespace qualifier, in case the sender omitted it
                attrName = (XmlAttribute)node.SelectSingleNode(secondaryXPath, dsmlNS);

                if (attrName == null)
                {
                    // the element doesn't have a associated dn
                    throw new DsmlInvalidDocumentException(Res.GetString(Res.MissingSearchResultEntryAttributeName));
                }

                _attributeName = attrName.Value;
            }
            else
            {
                _attributeName = attrName.Value;
            }

            // retrieve attribute value
            XmlNodeList nodeList = node.SelectNodes("dsml:value", dsmlNS);

            if (nodeList.Count != 0)
            {
                foreach (XmlNode valueNode in nodeList)
                {
                    Debug.Assert(valueNode is XmlElement);

                    XmlAttribute valueType = (XmlAttribute)valueNode.SelectSingleNode("@xsi:type", dsmlNS);

                    if (valueType == null)
                    {
                        // value type is string
                        Add(valueNode.InnerText);
                    }
                    else
                    {
                        // value type is string
                        if (string.Compare(valueType.Value, "xsd:string", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            Add(valueNode.InnerText);
                        }
                        else if (string.Compare(valueType.Value, "xsd:base64Binary", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            string base64EncodedValue = valueNode.InnerText;
                            byte[] binaryValue;
                            try
                            {
                                binaryValue = System.Convert.FromBase64String(base64EncodedValue);
                            }
                            catch (FormatException)
                            {
                                // server returned invalid base64
                                throw new DsmlInvalidDocumentException(Res.GetString(Res.BadBase64Value));
                            }

                            Add(binaryValue);
                        }
                        else if (string.Compare(valueType.Value, "xsd:anyURI", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            Uri uri = new Uri(valueNode.InnerText);
                            Add(uri);
                        }
                    }
                }
            }
        }