/// <summary>
 /// Commit changes made to persisted object in configuration database
 /// </summary>
 void UpdatePersistedObject()
 {
     // Update object in database
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {
         this.Web.AllowUnsafeUpdates = true;
         PersistedObject.Update();
         this.Web.AllowUnsafeUpdates = false;
     });
     ViewState["PersistedObjectVersion"] = PersistedObject.Version;
 }
Example #2
0
        public static AzureCPConfig ResetPersistedObject()
        {
            AzureCPConfig persistedObject = GetFromConfigDB();

            if (persistedObject != null)
            {
                AzureCPConfig newPersistedObject = GetDefaultSettings(persistedObject);
                newPersistedObject.Update();

                AzureCPLogging.Log(
                    String.Format("Claims list of PersistedObject {0} was successfully reset to default relationship table", Constants.AZURECPCONFIG_NAME),
                    TraceSeverity.High, EventSeverity.Information, AzureCPLogging.Categories.Core);
            }
            return(null);
        }
Example #3
0
        public static void ResetClaimsList()
        {
            AzureCPConfig persistedObject = GetFromConfigDB();

            if (persistedObject != null)
            {
                persistedObject.AzureADObjects.Clear();
                persistedObject.AzureADObjects = GetDefaultAADClaimTypeList();
                persistedObject.Update();

                AzureCPLogging.Log(
                    String.Format("Claims list of PersistedObject {0} was successfully reset to default relationship table", Constants.AZURECPCONFIG_NAME),
                    TraceSeverity.High, EventSeverity.Information, AzureCPLogging.Categories.Core);
            }
            return;
        }
Example #4
0
        /// <summary>
        /// Create the persisted object that contains default configuration of AzureCP.
        /// It should be created only in central administration with application pool credentials
        /// because this is the only place where we are sure user has the permission to write in the config database
        /// </summary>
        public static AzureCPConfig CreatePersistedObject()
        {
            // Ensure it doesn't already exists and delete it if so
            AzureCPConfig existingConfig = AzureCPConfig.GetFromConfigDB();

            if (existingConfig != null)
            {
                DeleteAzureCPConfig();
            }

            AzureCPConfig PersistedObject = new AzureCPConfig(SPFarm.Local);

            PersistedObject.Id           = new Guid(Constants.AZURECPCONFIG_ID);
            PersistedObject.AzureTenants = new List <AzureTenant>();
            PersistedObject = GetDefaultSettings(PersistedObject);
            PersistedObject.Update();
            AzureCPLogging.Log(
                String.Format("Created PersistedObject {0} with Id {1}", PersistedObject.Name, PersistedObject.Id),
                TraceSeverity.Medium, EventSeverity.Information, AzureCPLogging.Categories.Core);

            return(PersistedObject);
        }
Example #5
0
        protected void UpdatePersistedObject()
        {
            if (null == PersistedObject)
            {
                AzureCPLogging.Log(
                    String.Format("PersistedObject {0} should not be null.", Constants.AZURECPCONFIG_NAME),
                    TraceSeverity.Unexpected,
                    EventSeverity.Error,
                    AzureCPLogging.Categories.Configuration);
                return;
            }

            if (null == CurrentTrustedLoginProvider)
            {
                AzureCPLogging.Log(
                    "Trust associated with AzureCP could not be found.",
                    TraceSeverity.Unexpected,
                    EventSeverity.Error,
                    AzureCPLogging.Categories.Configuration);
                return;
            }

            // Update object in database
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                this.Web.AllowUnsafeUpdates = true;
                PersistedObject.Update();
                this.Web.AllowUnsafeUpdates = false;

                AzureCPLogging.Log(
                    String.Format("Objects list of AzureCP was successfully updated in PersistedObject {0}.", Constants.AZURECPCONFIG_NAME),
                    TraceSeverity.Medium,
                    EventSeverity.Information,
                    AzureCPLogging.Categories.Configuration);
            });
            ViewState["PersistedObjectVersion"] = PersistedObject.Version;
        }
Example #6
0
        /// <summary>
        /// Create the persisted object that contains default configuration of AzureCP.
        /// It should be created only in central administration with application pool credentials
        /// because this is the only place where we are sure user has the permission to write in the config database
        /// </summary>
        public static AzureCPConfig CreatePersistedObject()
        {
            // Ensure it doesn't already exists and delete it if so
            AzureCPConfig existingConfig = AzureCPConfig.GetFromConfigDB();
            if (existingConfig != null)
            {
                DeleteAzureCPConfig();
            }

            AzureCPConfig PersistedObject = new AzureCPConfig(SPFarm.Local);
            PersistedObject.Id = new Guid(Constants.AZURECPCONFIG_ID);
            PersistedObject.AzureTenants = new List<AzureTenant>();
            PersistedObject = GetDefaultSettings(PersistedObject);
            PersistedObject.Update();
            AzureCPLogging.Log(
                String.Format("Created PersistedObject {0} with Id {1}", PersistedObject.Name, PersistedObject.Id),
                TraceSeverity.Medium, EventSeverity.Information, AzureCPLogging.Categories.Core);

            return PersistedObject;
        }