示例#1
0
        protected void RenameExistingRole(RoleNameMapping mapping, string suffix)
        {
            ExTraceGlobals.AccessCheckTracer.TraceFunction <bool>(20005L, "-->RenameExistingRole: Mapping Is Null = {0}", mapping == null);
            if (mapping == null)
            {
                return;
            }
            string       text         = string.IsNullOrEmpty(suffix) ? mapping.OldName : (mapping.OldName + suffix);
            ExchangeRole exchangeRole = this.settings.ConfigurationSession.Read <ExchangeRole>(this.settings.RolesContainerId.GetChildId(text));

            if (exchangeRole != null)
            {
                this.settings.LogReadObject(exchangeRole);
                string text2 = string.IsNullOrEmpty(suffix) ? mapping.NewName : (mapping.NewName + suffix);
                exchangeRole.SetId(this.settings.RolesContainerId.GetChildId(text2));
                this.SaveRoleAndSuggestCleanupOnFailure(exchangeRole);
                ExTraceGlobals.AccessCheckTracer.TraceFunction <string, string>(20005L, "<--RenameExistingRole: Role Renamed. oldName = {0}, NewName = {1}", text, text2);
            }
        }
示例#2
0
        public ExchangeRole GenerateRole(List <string> enabledFeatures, ADObjectId rolesContainerId, string suffix, string resolutionType)
        {
            ExchangeRole exchangeRole = new ExchangeRole();
            string       input        = null;

            exchangeRole.SetId(rolesContainerId.GetChildId(this.RoleName + suffix));
            exchangeRole.RoleType         = this.roleType;
            exchangeRole.MailboxPlanIndex = resolutionType;
            exchangeRole.StampImplicitScopes();
            exchangeRole.StampIsEndUserRole();
            foreach (RoleCmdlet roleCmdlet in this.cmdlets)
            {
                if (roleCmdlet.TryGenerateRoleEntry(enabledFeatures, ref input))
                {
                    exchangeRole.RoleEntries.Add(RoleEntry.Parse(input));
                }
            }
            return(exchangeRole);
        }
        protected ExchangeRole CreateCustomizedDerivedRole(ExchangeRole parentRole, List <RoleEntry> roleEntries, string unmatchedRoleName)
        {
            ExTraceGlobals.AccessCheckTracer.TraceFunction <string, string>(20008L, "--->CreateCustomizedDerivedRole: parentRole = {0}, unmatchedRoleName = {1}", parentRole.Name, unmatchedRoleName);
            ADObjectId adobjectId = parentRole.Id;

            if (!parentRole.IsRootRole)
            {
                adobjectId = adobjectId.Parent;
            }
            string text = string.Format("auto_{0}_{1}", unmatchedRoleName, adobjectId.Name).Trim();

            if (text.Length > 64)
            {
                text = text.Substring(0, 64).Trim();
            }
            ExTraceGlobals.AccessCheckTracer.TraceFunction <string>(20008L, "----customRoleName {0}", text);
            ADObjectId   childId      = adobjectId.GetChildId(text);
            ExchangeRole exchangeRole = this.settings.ConfigurationSession.Read <ExchangeRole>(childId);

            if (exchangeRole != null)
            {
                this.settings.LogReadObject(exchangeRole);
                if (exchangeRole.RoleType != parentRole.RoleType || !exchangeRole.ExchangeVersion.Equals(parentRole.ExchangeVersion) || exchangeRole.RoleState != parentRole.RoleState)
                {
                    this.settings.WriteError(new ExRBACFailedToUpdateCustomRole(unmatchedRoleName, text, exchangeRole.ToString()), ErrorCategory.ResourceExists, null);
                }
                exchangeRole.RoleEntries = new MultiValuedProperty <RoleEntry>(roleEntries);
                base.SaveDerivedRoleAndWarnOnValidationErrors(exchangeRole);
                ExTraceGlobals.AccessCheckTracer.TraceFunction(20008L, "<--CreateCustomizedDerivedRole: Role Updated");
            }
            else
            {
                ExchangeRole exchangeRole2 = new ExchangeRole();
                exchangeRole2.ProvisionalClone(parentRole);
                exchangeRole2.RoleEntries = new MultiValuedProperty <RoleEntry>(roleEntries);
                exchangeRole2.SetId(childId);
                base.SaveRoleAndSuggestCleanupOnFailure(exchangeRole2);
                exchangeRole = exchangeRole2;
                ExTraceGlobals.AccessCheckTracer.TraceFunction(20008L, "<--CreateCustomizedDerivedRole: New Custom Role created");
            }
            return(exchangeRole);
        }