예제 #1
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (!this.Force && SharedConfiguration.IsSharedConfiguration(this.DataObject.OrganizationId) && !base.ShouldContinue(Strings.ConfirmSharedConfiguration(this.DataObject.OrganizationId.OrganizationalUnit.Name)))
            {
                TaskLogger.LogExit();
                return;
            }
            IConfigurationSession configurationSession = null;

            base.InternalProcessRecord();
            if (this.WellKnownObjectGuid != Guid.Empty || this.roleAssignments != null)
            {
                configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, false, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 676, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RBAC\\RoleGroup\\NewRoleGroup.cs");
                configurationSession.LinkResolutionServer = this.DataObject.OriginatingServer;
            }
            if (this.WellKnownObjectGuid != Guid.Empty)
            {
                try
                {
                    RoleGroupCommon.StampWellKnownObjectGuid(configurationSession, this.DataObject.OrganizationId, this.DataObject.DistinguishedName, this.WellKnownObjectGuid);
                }
                catch (Exception)
                {
                    this.DataObject.ExternalDirectoryObjectId = null;
                    base.DataSession.Save(this.DataObject);
                    base.DataSession.Delete(this.DataObject);
                    throw;
                }
            }
            if (this.roleAssignments != null)
            {
                List <ExchangeRoleAssignment> list = new List <ExchangeRoleAssignment>();
                string id = string.Empty;
                try
                {
                    foreach (ExchangeRoleAssignment exchangeRoleAssignment in this.roleAssignments)
                    {
                        exchangeRoleAssignment.User = this.DataObject.Id;
                        id = exchangeRoleAssignment.Id.Name;
                        configurationSession.Save(exchangeRoleAssignment);
                        list.Add(exchangeRoleAssignment);
                    }
                }
                catch (Exception)
                {
                    this.WriteWarning(Strings.WarningCouldNotCreateRoleAssignment(id, this.Name));
                    foreach (ExchangeRoleAssignment exchangeRoleAssignment2 in list)
                    {
                        base.WriteVerbose(Strings.VerboseRemovingRoleAssignment(exchangeRoleAssignment2.Id.ToString()));
                        configurationSession.Delete(exchangeRoleAssignment2);
                        base.WriteVerbose(Strings.VerboseRemovedRoleAssignment(exchangeRoleAssignment2.Id.ToString()));
                    }
                    base.WriteVerbose(Strings.VerboseRemovingRoleGroup(this.DataObject.Id.ToString()));
                    base.DataSession.Delete(this.DataObject);
                    throw;
                }
            }
            TaskLogger.LogExit();
        }
 private void RemoveEdgeFromConnectorSourceServers(IConfigurationSession scSession, Server server)
 {
     SmtpSendConnectorConfig[] array = scSession.Find <SmtpSendConnectorConfig>(null, QueryScope.SubTree, null, null, -1);
     foreach (SmtpSendConnectorConfig smtpSendConnectorConfig in array)
     {
         if (smtpSendConnectorConfig != null && smtpSendConnectorConfig.SourceTransportServers != null)
         {
             MultiValuedProperty <ADObjectId> sourceTransportServers = smtpSendConnectorConfig.SourceTransportServers;
             ADObjectId adobjectId = null;
             foreach (ADObjectId adobjectId2 in sourceTransportServers)
             {
                 if (adobjectId2.Name == server.Id.Name)
                 {
                     if (smtpSendConnectorConfig.SourceTransportServers.Count == 1)
                     {
                         scSession.Delete(smtpSendConnectorConfig);
                     }
                     else
                     {
                         adobjectId = adobjectId2;
                     }
                 }
             }
             if (adobjectId != null)
             {
                 sourceTransportServers.Remove(adobjectId);
                 smtpSendConnectorConfig.SourceTransportServers = sourceTransportServers;
                 scSession.Save(smtpSendConnectorConfig);
             }
         }
     }
 }
 private void RollbackChanges(IConfigurationSession writableConfigSession, List <ExchangeRoleAssignment> createdRoleAssignments)
 {
     foreach (ExchangeRoleAssignment exchangeRoleAssignment in createdRoleAssignments)
     {
         base.WriteVerbose(Strings.VerboseRemovingRoleAssignment(exchangeRoleAssignment.Id.ToString()));
         writableConfigSession.Delete(exchangeRoleAssignment);
         base.WriteVerbose(Strings.VerboseRemovedRoleAssignment(exchangeRoleAssignment.Id.ToString()));
     }
     base.WriteVerbose(Strings.VerboseRemovingRoleAssignmentPolicy(this.DataObject.Id.ToString()));
     base.DataSession.Delete(this.DataObject);
 }
예제 #4
0
 // Token: 0x06000597 RID: 1431 RVA: 0x00021628 File Offset: 0x0001F828
 private static void DeleteObject(IConfigurationSession scopedSession, ADConfigurationObject adObject)
 {
     try
     {
         ADNotificationAdapter.RunADOperation(delegate()
         {
             scopedSession.Delete(adObject);
         });
         DeviceClassCache.UpdateProtocolLogLastUsedDC(scopedSession);
         AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Deleted object: {0}", adObject.Id.DistinguishedName);
     }
     catch (LocalizedException ex)
     {
         AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.RequestsTracer, null, "Failed to delete object {0} because: {1}", adObject.Id.DistinguishedName, ex.Message);
     }
 }
예제 #5
0
 internal static void Delete(IConfigurationSession configSession, MRSRequestWrapper instance)
 {
     configSession.Delete(instance);
 }
        internal static bool RevertExpiredThrottlingPolicyIfNeeded(IPowerShellBudget budget)
        {
            if (budget == null)
            {
                return(false);
            }
            bool result;

            using (new MonitoredScope("PowerShellThrottlingPolicyUpdater", "RevertExpiredThrottlingPolicyIfNeeded", AuthZLogHelper.AuthZPerfMonitors))
            {
                ThrottlingPolicy throttlingPolicy = null;
                try
                {
                    throttlingPolicy = ((EffectiveThrottlingPolicy)budget.ThrottlingPolicy).ThrottlingPolicy;
                    Match    match = Regex.Match(throttlingPolicy.Name, "^\\[(?<expiredtime>[0-9]{4}(-[0-9]{2}){2}T([0-9]{2}:){2}[0-9]{2})\\](?<orginalname>.+)", RegexOptions.Compiled);
                    DateTime t;
                    if (!match.Success)
                    {
                        result = false;
                    }
                    else if (!DateTime.TryParse(match.Groups["expiredtime"].Value, out t))
                    {
                        AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Unrecognized time format in throttling policy '{0}'.", throttlingPolicy.Name));
                        result = false;
                    }
                    else if (t > DateTime.UtcNow)
                    {
                        AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Throttlling policy '{0}' is not expired yet.", throttlingPolicy.Name));
                        result = false;
                    }
                    else
                    {
                        IConfigurationSession configuationSession      = PowerShellThrottlingPolicyUpdater.GetConfiguationSession(throttlingPolicy.OrganizationId);
                        ThrottlingPolicy      writableThrottlingPolicy = PowerShellThrottlingPolicyUpdater.GetWritableThrottlingPolicy(configuationSession, throttlingPolicy);
                        if (writableThrottlingPolicy == null || writableThrottlingPolicy.Name != throttlingPolicy.Name)
                        {
                            AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Throttlling policy '{0}' is updated and don't need to be expired.", throttlingPolicy.Name));
                            result = false;
                        }
                        else
                        {
                            string arg;
                            if (PowerShellThrottlingPolicyUpdater.RevertBackupThrottlingSettings(writableThrottlingPolicy, out arg))
                            {
                                writableThrottlingPolicy.Name = match.Groups["orginalname"].Value;
                                configuationSession.Save(writableThrottlingPolicy);
                                AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Revert throttling policy '{0}' to name: {1} and restore backup throttling value: {2}.", throttlingPolicy.Name, writableThrottlingPolicy.Name, arg));
                            }
                            else
                            {
                                PowerShellThrottlingPolicyUpdater.ClearThrottlingPolicyAssoicate(PowerShellThrottlingPolicyUpdater.GetRecipientSession(throttlingPolicy.OrganizationId), throttlingPolicy);
                                configuationSession.Delete(writableThrottlingPolicy);
                                AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Delete throttling policy '{0}' and clear associates with it.", throttlingPolicy.Name));
                            }
                            result = true;
                        }
                    }
                }
                catch (TransientException arg2)
                {
                    AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Occur transient exception on revert throttling policy '{0}': {1}", (throttlingPolicy != null) ? throttlingPolicy.Name : string.Empty, arg2));
                    result = false;
                }
                catch (Exception ex)
                {
                    AuthZLogger.SafeAppendGenericError("PowerShellThrottlingPolicyUpdater", string.Format("Error on revert throttling policy '{0}': {1}", (throttlingPolicy != null) ? throttlingPolicy.Name : string.Empty, ex), KnownException.IsUnhandledException(ex));
                    result = false;
                }
            }
            return(result);
        }