Ejemplo n.º 1
0
        private bool IsNonDeprecatedRole()
        {
            ExchangeRole exchangeRole = (ExchangeRole)base.GetDataObject <ExchangeRole>(new RoleIdParameter(this.DataObject.Role), base.DataSession, null, new LocalizedString?(Strings.ErrorRoleNotFound(this.DataObject.Role.ToString())), new LocalizedString?(Strings.ErrorRoleNotUnique(this.DataObject.Role.ToString())));

            if (exchangeRole != null && exchangeRole.IsDeprecated)
            {
                this.WriteWarning(Strings.ErrorCannotMoveRoleAssignmentOfDeprecatedRole(exchangeRole.ToString()));
                return(false);
            }
            return(true);
        }
        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);
        }