示例#1
0
        internal static RoleGroup PopulateRoleAssignmentsAndConvert(ADGroup group, IConfigurationSession configurationSession)
        {
            Result <ExchangeRoleAssignment>[] roleAssignmentResults = null;
            if (RoleGroup.ContainsRoleAssignments(group))
            {
                return(new RoleGroup(group, roleAssignmentResults));
            }
            SharedConfiguration sharedConfiguration = SharedConfiguration.GetSharedConfiguration(group.OrganizationId);
            RoleGroup           roleGroup;

            if (sharedConfiguration != null)
            {
                if (group.RoleGroupType == RoleGroupType.PartnerLinked)
                {
                    roleGroup = new RoleGroup(group, null);
                }
                else
                {
                    ADObjectId   sharedConfiguration2 = null;
                    ADObjectId[] sharedRoleGroupIds;
                    if (group.IsModified(ADObjectSchema.Name))
                    {
                        sharedRoleGroupIds = sharedConfiguration.GetSharedRoleGroupIds(new ADObjectId[]
                        {
                            group.OriginalId
                        });
                    }
                    else
                    {
                        sharedRoleGroupIds = sharedConfiguration.GetSharedRoleGroupIds(new ADObjectId[]
                        {
                            group.Id
                        });
                    }
                    if (sharedRoleGroupIds != null && sharedRoleGroupIds.Length != 0)
                    {
                        IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, sharedConfiguration.GetSharedConfigurationSessionSettings(), 171, "PopulateRoleAssignmentsAndConvert", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RBAC\\RoleGroup\\RoleGroupCommon.cs");
                        roleAssignmentResults = tenantOrTopologyConfigurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[]
                        {
                            sharedRoleGroupIds[0]
                        }, false);
                        sharedConfiguration2 = sharedConfiguration.SharedConfigurationCU.Id;
                    }
                    roleGroup = new RoleGroup(group, roleAssignmentResults);
                    roleGroup.SharedConfiguration = sharedConfiguration2;
                }
            }
            else
            {
                configurationSession.SessionSettings.IsSharedConfigChecked = true;
                roleAssignmentResults = configurationSession.FindRoleAssignmentsByUserIds(new ADObjectId[]
                {
                    group.Id
                }, false);
                roleGroup = new RoleGroup(group, roleAssignmentResults);
            }
            return(roleGroup);
        }
示例#2
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADGroup adgroup = (ADGroup)base.PrepareDataObject();

            adgroup.BypassModerationCheck = true;
            if (this.SmtpAndX500Addresses != null && this.SmtpAndX500Addresses.Count > 0)
            {
                adgroup.EmailAddresses = SyncTaskHelper.ReplaceSmtpAndX500Addresses(this.SmtpAndX500Addresses, adgroup.EmailAddresses);
            }
            if (base.Fields.IsModified("SipAddresses"))
            {
                adgroup.EmailAddresses = SyncTaskHelper.ReplaceSipAddresses(this.SipAddresses, adgroup.EmailAddresses);
            }
            if (adgroup.IsModified(MailEnabledRecipientSchema.EmailAddresses))
            {
                adgroup.EmailAddresses = SyncTaskHelper.FilterDuplicateEmailAddresses(base.TenantGlobalCatalogSession, adgroup.EmailAddresses, adgroup, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            if (base.Fields.IsModified(ADGroupSchema.GroupType))
            {
                if (this.Type != GroupType.Distribution && this.Type != GroupType.Security)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorGroupTypeInvalid), ExchangeErrorCategory.Client, null);
                }
                bool flag = (adgroup.GroupType & GroupTypeFlags.SecurityEnabled) == GroupTypeFlags.SecurityEnabled;
                if (this.Type == GroupType.Distribution && flag)
                {
                    adgroup.GroupType &= (GroupTypeFlags)2147483647;
                    if ((adgroup.GroupType & GroupTypeFlags.Universal) == GroupTypeFlags.Universal)
                    {
                        adgroup.RecipientTypeDetails = RecipientTypeDetails.MailUniversalDistributionGroup;
                    }
                    else
                    {
                        adgroup.RecipientTypeDetails = RecipientTypeDetails.MailNonUniversalGroup;
                    }
                    base.DesiredRecipientType = adgroup.RecipientType;
                    if (!adgroup.IsChanged(ADRecipientSchema.RecipientDisplayType))
                    {
                        adgroup.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.DistributionGroup);
                    }
                }
                else if (this.Type == GroupType.Security && !flag)
                {
                    if (adgroup.RecipientTypeDetails == RecipientTypeDetails.RoomList)
                    {
                        base.WriteError(new TaskInvalidOperationException(Strings.ErrorConvertNonUniversalDistributionGroup(adgroup.Identity.ToString())), ExchangeErrorCategory.Client, adgroup.Identity);
                    }
                    adgroup.GroupType |= GroupTypeFlags.SecurityEnabled;
                    if ((adgroup.GroupType & GroupTypeFlags.Universal) == GroupTypeFlags.Universal)
                    {
                        adgroup.RecipientTypeDetails = RecipientTypeDetails.MailUniversalSecurityGroup;
                    }
                    else
                    {
                        adgroup.RecipientTypeDetails = RecipientTypeDetails.MailNonUniversalGroup;
                    }
                    base.DesiredRecipientType = adgroup.RecipientType;
                    if (!adgroup.IsChanged(ADRecipientSchema.RecipientDisplayType))
                    {
                        adgroup.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.SecurityDistributionGroup);
                    }
                }
            }
            TaskLogger.LogExit();
            return(adgroup);
        }