Example #1
0
		protected virtual void AddPrefixIfNeeded(XmlDictionaryWriter writer, string prefix, string ns)
		{
			if (writer.LookupPrefix(ns) == null)
			{
				writer.WriteXmlnsAttribute(prefix, ns);
			}
		}
Example #2
0
 internal static void AddNamespaceDeclaration(XmlDictionaryWriter writer, string prefix, XmlDictionaryString ns)
 {
     string p = writer.LookupPrefix(ns.Value);
     if (p == null || p != prefix)
     {
         writer.WriteXmlnsAttribute(prefix, ns);
     }
 }
Example #3
0
		protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
		{
			writer.WriteStartElement("BaseObjectSearchRequest", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
			writer.WriteAttributeString("Dialect", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Dialect/XPath-Level-1");
			base.OnWriteBodyContents(writer);
			string str = writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory/Data");
			string str1 = writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory");
			if (this._attributeList != null)
			{
				XmlUtility.SerializeAttributeList(writer, "AttributeType", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess", str1, str, this._attributeList);
			}
			if (this._controls != null)
			{
				DirectoryControlSerializer.Serialize(writer, this._controls);
			}
			writer.WriteEndElement();
		}
Example #4
0
        internal static string EnsureNamespaceDefined(XmlDictionaryWriter writer, XmlDictionaryString ns, string defaultPrefix)
        {
            string p = writer.LookupPrefix(ns.Value);
            if (p == null)
            {
                writer.WriteXmlnsAttribute(defaultPrefix, ns);
                p = defaultPrefix;
            }

            return p;
        }
Example #5
0
		protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer)
		{
			base.OnWriteStartEnvelope(writer);
			writer.WriteXmlnsAttribute("addata", "http://schemas.microsoft.com/2008/1/ActiveDirectory/Data");
			writer.WriteXmlnsAttribute("ad", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
			writer.WriteXmlnsAttribute("xsd", "http://www.w3.org/2001/XMLSchema");
			writer.WriteXmlnsAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance");
			if (writer.LookupPrefix("http://www.w3.org/2005/08/addressing") == null)
			{
				writer.WriteXmlnsAttribute("wsa", "http://www.w3.org/2005/08/addressing");
			}
		}
        /// <summary>
        /// When overridden in a non-abstract derived class, writes the contents of the detail element. 
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlDictionaryWriter"/> used to write the detail element.</param>
        protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
        {
            var prefix = writer.LookupPrefix(this._nameSpace) ?? "web";
            using (var reader = this._messageFault.GetReaderAtDetailContents())
            {
                if ("Error".Equals(reader.LocalName) && string.IsNullOrWhiteSpace(reader.NamespaceURI))
                {
                    writer.WriteStartElement(prefix, "Error", this._nameSpace);
                    reader.Read();

                    // ErrorMessage
                    writer.WriteNode(reader, false);

                    // ErrorNumber
                    writer.WriteNode(reader, false);

                    // 
                    writer.WriteNode(reader, false);
                }
            }
        }
Example #7
0
		protected virtual void OnWriteStartHeader (XmlDictionaryWriter writer, MessageVersion version)
		{
			var dic = Constants.SoapDictionary;
			XmlDictionaryString name, ns;
			var prefix = Prefix ?? (Namespace.Length > 0 ? writer.LookupPrefix (Namespace) : String.Empty);
			if (dic.TryLookup (Name, out name) && dic.TryLookup (Namespace, out ns))
				writer.WriteStartElement (prefix, name, ns);
			else
				writer.WriteStartElement (prefix, this.Name, this.Namespace);
			WriteHeaderAttributes (writer, version);
		}
Example #8
0
		public static void WriteXsiTypeAttribute(XmlDictionaryWriter writer, string xsdType)
		{
			string str = writer.LookupPrefix("http://www.w3.org/2001/XMLSchema");
			object[] objArray = new object[2];
			objArray[0] = str;
			objArray[1] = xsdType;
			writer.WriteAttributeString("type", "http://www.w3.org/2001/XMLSchema-instance", string.Format(CultureInfo.CurrentCulture, "{0}:{1}", objArray));
		}
		private static void InternalSerialize(XmlDictionaryWriter writer, ChangeOperation ChangeOperation, string ns, string property, object value)
		{
			string str = writer.LookupPrefix(ns);
			writer.LookupPrefix("http://schemas.microsoft.com/2008/1/ActiveDirectory");
			if (ChangeOperation != ChangeOperation.None)
			{
				writer.WriteStartElement("Change", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
				ChangeOperation changeOperation = ChangeOperation;
				switch (changeOperation)
				{
					case ChangeOperation.Add:
					{
						writer.WriteAttributeString("Operation", "add");
						break;
					}
					case ChangeOperation.Delete:
					{
						writer.WriteAttributeString("Operation", "delete");
						break;
					}
					case ChangeOperation.Replace:
					{
						writer.WriteAttributeString("Operation", "replace");
						break;
					}
				}
			}
			else
			{
				writer.WriteStartElement("AttributeTypeAndValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
			}
			writer.WriteElementString("AttributeType", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess", AttributeTypeAndValueSerializer.FormatAttributeName(str, property));
			if (value != null)
			{
				if (value as ICollection == null)
				{
					writer.WriteStartElement("AttributeValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
					if (value as DirectoryAttributeModification == null)
					{
						ADValueSerializer.Serialize(writer, value);
					}
					else
					{
						DirectoryAttributeModification directoryAttributeModification = (DirectoryAttributeModification)value;
						ADValueSerializer.Serialize(writer, directoryAttributeModification[0]);
					}
					writer.WriteEndElement();
				}
				else
				{
					ICollection collections = (ICollection)value;
					if (collections.Count > 0)
					{
						writer.WriteStartElement("AttributeValue", "http://schemas.microsoft.com/2006/11/IdentityManagement/DirectoryAccess");
						foreach (object obj in collections)
						{
							ADValueSerializer.Serialize(writer, obj);
						}
						writer.WriteEndElement();
					}
				}
			}
			writer.WriteEndElement();
		}
Example #10
0
 public override string LookupPrefix(string ns)
 {
     return(writer.LookupPrefix(ns));
 }
 public virtual void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)
 {
     this.CheckObjectValidity();
     if (writer == null)
     {
         throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));
     }
     if (samlSerializer == null)
     {
         throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
     }
     SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
     writer.WriteStartElement(samlDictionary.PreferredPrefix.Value, samlDictionary.AuthorityBinding, samlDictionary.Namespace);
     string prefix = null;
     if (!string.IsNullOrEmpty(this.authorityKind.Namespace))
     {
         writer.WriteAttributeString(string.Empty, samlDictionary.NamespaceAttributePrefix.Value, null, this.authorityKind.Namespace);
         prefix = writer.LookupPrefix(this.authorityKind.Namespace);
     }
     writer.WriteStartAttribute(samlDictionary.AuthorityKind, null);
     if (string.IsNullOrEmpty(prefix))
     {
         writer.WriteString(this.authorityKind.Name);
     }
     else
     {
         writer.WriteString(prefix + ":" + this.authorityKind.Name);
     }
     writer.WriteEndAttribute();
     writer.WriteStartAttribute(samlDictionary.Location, null);
     writer.WriteString(this.location);
     writer.WriteEndAttribute();
     writer.WriteStartAttribute(samlDictionary.Binding, null);
     writer.WriteString(this.binding);
     writer.WriteEndAttribute();
     writer.WriteEndElement();
 }
        public virtual void WriteXml(XmlDictionaryWriter writer, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer)
        {
            CheckObjectValidity();

            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));

            if (samlSerializer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));

#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
            SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;

            writer.WriteStartElement(dictionary.PreferredPrefix.Value, dictionary.AuthorityBinding, dictionary.Namespace);

            string prefix = null;
            if (!string.IsNullOrEmpty(this.authorityKind.Namespace))
            {
                writer.WriteAttributeString(String.Empty, dictionary.NamespaceAttributePrefix.Value, null, this.authorityKind.Namespace);
                prefix = writer.LookupPrefix(this.authorityKind.Namespace);
            }

            writer.WriteStartAttribute(dictionary.AuthorityKind, null);
            if (string.IsNullOrEmpty(prefix))
                writer.WriteString(this.authorityKind.Name);
            else
                writer.WriteString(prefix + ":" + this.authorityKind.Name);
            writer.WriteEndAttribute();

            writer.WriteStartAttribute(dictionary.Location, null);
            writer.WriteString(this.location);
            writer.WriteEndAttribute();

            writer.WriteStartAttribute(dictionary.Binding, null);
            writer.WriteString(this.binding);
            writer.WriteEndAttribute();

            writer.WriteEndElement();
        }