Esempio n. 1
0
        public static void DeserializeSingleValue <T>(XmlReader reader, out T value)
        {
            object obj  = null;
            Type   type = null;

            ADValueSerializer.Deserialize(reader, false, out obj, out type);
            value = (T)obj;
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        public static void Deserialize(XmlReader reader, bool useInternStrings, out object value)
        {
            Type type = null;

            ADValueSerializer.Deserialize(reader, useInternStrings, out value, out type);
        }
Esempio n. 4
0
        private static void DeserializeAttributeElement(XmlReader reader, ResultSerializer.ResultDialect dialect, ADWSResultEntry entry)
        {
            string str  = null;
            string str1 = null;
            string str2 = null;
            string str3 = null;
            bool   flag = false;

            if (string.IsNullOrEmpty(reader.Prefix))
            {
                if (!string.Equals(reader.NamespaceURI, "http://schemas.microsoft.com/2008/1/ActiveDirectory", StringComparison.Ordinal))
                {
                    flag = false;
                }
                else
                {
                    flag = true;
                }
            }
            else
            {
                string str4 = reader.LookupNamespace(reader.Prefix);
                if (!string.Equals(str4, "http://schemas.microsoft.com/2008/1/ActiveDirectory", StringComparison.Ordinal))
                {
                    flag = false;
                    //reader.Prefix;
                }
                else
                {
                    flag = true;
                    //reader.Prefix;
                }
            }
            if (!flag)
            {
                bool   flag1 = false;
                string str5  = string.Intern(reader.LocalName);
                if (str5.Equals("objectClass", StringComparison.OrdinalIgnoreCase))
                {
                    flag1 = true;
                }
                XmlUtility.DeserializeLdapAttributeOption(reader, ref str5);
                object obj = null;
                reader.Read();
                ADValueSerializer.Deserialize(reader, flag1, out obj);
                entry.DirObject.SetValue(str5, new ADPropertyValueCollection(obj));
                reader.ReadEndElement();
                return;
            }
            else
            {
                string localName = reader.LocalName;
                if (!string.Equals(localName, "container-hierarchy-parent", StringComparison.Ordinal))
                {
                    if (!string.Equals(localName, "distinguishedName", StringComparison.Ordinal))
                    {
                        if (!string.Equals(localName, "relativeDistinguishedName", StringComparison.Ordinal))
                        {
                            if (!string.Equals(localName, "objectReferenceProperty", StringComparison.Ordinal))
                            {
                                throw new ArgumentException(string.Format(StringResources.ADWSXmlParserInvalidAttribute, localName));
                            }
                            else
                            {
                                reader.ReadStartElement("objectReferenceProperty", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                                ADValueSerializer.DeserializeSingleValue <string>(reader, out str3);
                                entry.ObjectReferenceProperty = str3;
                                reader.ReadEndElement();
                                return;
                            }
                        }
                        else
                        {
                            reader.ReadStartElement("relativeDistinguishedName", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                            ADValueSerializer.DeserializeSingleValue <string>(reader, out str2);
                            entry.RelativeDistinguishedName = str2;
                            reader.ReadEndElement();
                            return;
                        }
                    }
                    else
                    {
                        reader.ReadStartElement("distinguishedName", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                        ADValueSerializer.DeserializeSingleValue <string>(reader, out str1);
                        entry.DistinguishedName = str1;
                        reader.ReadEndElement();
                        return;
                    }
                }
                else
                {
                    reader.ReadStartElement("container-hierarchy-parent", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
                    ADValueSerializer.DeserializeSingleValue <string>(reader, out str);
                    entry.ParentContainer = str;
                    reader.ReadEndElement();
                    return;
                }
            }
        }