Ejemplo n.º 1
0
        public IMailboxBuilder <GroupMailbox> BuildFromDirectory(ADRawEntry rawEntry)
        {
            this.Mailbox.Alias                              = (rawEntry[GroupMailboxSchema.Alias] as string);
            this.Mailbox.DisplayName                        = (rawEntry[GroupMailboxSchema.DisplayName] as string);
            this.Mailbox.Owners                             = (rawEntry[GroupMailboxSchema.Owners] as MultiValuedProperty <ADObjectId>);
            this.Mailbox.SmtpAddress                        = (SmtpAddress)rawEntry[GroupMailboxSchema.PrimarySmtpAddress];
            this.Mailbox.Type                               = (ModernGroupObjectType)rawEntry[GroupMailboxSchema.ModernGroupType];
            this.Mailbox.SharePointUrl                      = (rawEntry[GroupMailboxSchema.SharePointUrl] as Uri);
            this.Mailbox.SharePointSiteUrl                  = (rawEntry[GroupMailboxSchema.SharePointSiteUrl] as string);
            this.Mailbox.SharePointDocumentsUrl             = (rawEntry[GroupMailboxSchema.SharePointDocumentsUrl] as string);
            this.Mailbox.RequireSenderAuthenticationEnabled = (bool)rawEntry[GroupMailboxSchema.RequireSenderAuthenticationEnabled];
            this.Mailbox.AutoSubscribeNewGroupMembers       = (bool)rawEntry[GroupMailboxSchema.AutoSubscribeNewGroupMembers];
            MultiValuedProperty <CultureInfo> multiValuedProperty = rawEntry[GroupMailboxSchema.Languages] as MultiValuedProperty <CultureInfo>;

            if (multiValuedProperty != null)
            {
                this.Mailbox.Language = multiValuedProperty.FirstOrDefault <CultureInfo>();
            }
            MultiValuedProperty <string> multiValuedProperty2 = rawEntry[GroupMailboxSchema.Description] as MultiValuedProperty <string>;

            if (multiValuedProperty2 != null)
            {
                this.Mailbox.Description = multiValuedProperty2.FirstOrDefault <string>();
            }
            return(this);
        }
        internal static object QuotaSettingGetter(ADPropertyDefinition adPropertyDefinition, IPropertyBag propertyBag)
        {
            if (adPropertyDefinition == null)
            {
                throw new ArgumentNullException("adPropertyDefinition");
            }
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings];
            string quotaSettingIdentifier = adPropertyDefinition.Name + ':';
            object result = adPropertyDefinition.DefaultValue;

            if (multiValuedProperty != null && multiValuedProperty.Count > 0)
            {
                string text = multiValuedProperty.FirstOrDefault((string item) => item.StartsWith(quotaSettingIdentifier, StringComparison.Ordinal));
                if (!string.IsNullOrEmpty(text))
                {
                    try
                    {
                        result = ValueConvertor.ConvertValueFromString(text.Substring(quotaSettingIdentifier.Length), adPropertyDefinition.Type, null);
                    }
                    catch (FormatException ex)
                    {
                        PropertyValidationError error = new PropertyValidationError(DirectoryStrings.CannotCalculateProperty(adPropertyDefinition.Name, ex.Message), adPropertyDefinition, propertyBag[DataClassificationConfigSchema.DataClassificationConfigQuotaSettings]);
                        throw new DataValidationException(error, ex);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
 internal static void MergeBindings(MultiValuedProperty <BindingMetadata> bindings, MultiValuedProperty <BindingMetadata> addedBindings, MultiValuedProperty <BindingMetadata> removedBindings, bool forceClear)
 {
     ArgumentValidator.ThrowIfNull("bindings", bindings);
     ArgumentValidator.ThrowIfNull("addedBindings", addedBindings);
     ArgumentValidator.ThrowIfNull("removedBindings", removedBindings);
     if (forceClear && bindings.Any <BindingMetadata>())
     {
         bindings.Clear();
         return;
     }
     using (MultiValuedProperty <BindingMetadata> .Enumerator enumerator = removedBindings.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             BindingMetadata item            = enumerator.Current;
             BindingMetadata bindingMetadata = bindings.FirstOrDefault((BindingMetadata p) => p.ImmutableIdentity == item.ImmutableIdentity);
             if (bindingMetadata != null)
             {
                 bindings.Remove(bindingMetadata);
             }
         }
     }
     using (MultiValuedProperty <BindingMetadata> .Enumerator enumerator2 = addedBindings.GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             BindingMetadata item             = enumerator2.Current;
             BindingMetadata bindingMetadata2 = bindings.FirstOrDefault((BindingMetadata p) => p.ImmutableIdentity == item.ImmutableIdentity);
             if (bindingMetadata2 == null)
             {
                 bindings.Add(item);
             }
             else if (!string.Equals(bindingMetadata2.DisplayName, item.DisplayName, StringComparison.InvariantCulture) || !string.Equals(bindingMetadata2.Name, item.Name, StringComparison.InvariantCultureIgnoreCase))
             {
                 int index = bindings.IndexOf(bindingMetadata2);
                 bindings[index] = item;
             }
         }
     }
 }
Ejemplo n.º 4
0
        public static object RedactCertificate(object value, out string[] raw, out string[] redacted)
        {
            raw      = null;
            redacted = null;
            MultiValuedProperty <byte[]> multiValuedProperty = value as MultiValuedProperty <byte[]>;

            if (multiValuedProperty == null)
            {
                return(null);
            }
            MultiValuedProperty <byte[]> multiValuedProperty2 = new MultiValuedProperty <byte[]>();

            if (multiValuedProperty.Count == 0 || multiValuedProperty.FirstOrDefault <byte[]>() == null)
            {
                return(multiValuedProperty2);
            }
            multiValuedProperty2.Add(new byte[128]);
            return(multiValuedProperty2);
        }