コード例 #1
0
        /// <summary>
        /// Enables/disables the specified application.
        /// </summary>
        /// <param name="appName">The name of the application.</param>
        /// <param name="enable">Value indicating whether to enable or disable the application.</param>
        public static void EnableApplication(string appName, bool enable)
        {
            ISSOAdmin2 ssoAdmin = new ISSOAdmin2();
            int        flagMask = SSOFlag.SSO_FLAG_ENABLED;
            int        flags    = enable ? SSOFlag.SSO_FLAG_ENABLED : SSOFlag.SSO_FLAG_NONE;

            ssoAdmin.UpdateApplication(appName, null, null, null, null, flags, flagMask);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new application in the SSO store using specified
        /// ISSOAdmin2 object instance and the configuration information.
        /// Creates both, the application and fields.
        /// </summary>
        /// <remarks>
        /// For internal use only. Assumes a TransactionScope is created before
        /// calling this method.
        /// </remarks>
        /// <param name="ssoAdmin">ISSOAdmin2 instance.</param>
        /// <param name="appConfig">Configuration information used to create the application.</param>
        private static void CreateApplication(ISSOAdmin2 ssoAdmin, SSOAppConfig appConfig)
        {
            // set default contact
            appConfig.AppInfo.Contact = SSOManager.DefaultContact;

            // fix the fieldCount when creating an application with no fields
            int fieldCount = Math.Max(1, appConfig.AppFields.Count);

            // create the sso application
            ssoAdmin.CreateApplication(
                appConfig.AppInfo.Name,
                appConfig.AppInfo.Description,
                appConfig.AppInfo.Contact,
                appConfig.AppInfo.UserAccounts,
                appConfig.AppInfo.AdminAccounts,
                appConfig.AppInfo.Flags & ~SSOFlag.SSO_FLAG_ENABLED, // the SSO_FLAG_ENABLED flag cannot be specified when creating an SSO application
                fieldCount);

            // create dummy field in the first slot
            ssoAdmin.CreateFieldInfo(appConfig.AppInfo.Name, "(unused)", SSOFlag.SSO_FLAG_NONE);
            // create the actual fields
            foreach (SSOAppField field in appConfig.AppFields)
            {
                // set field flags
                int fieldFlags = SSOFlag.SSO_FLAG_NONE;
                if (field.Masked == true)
                {
                    fieldFlags |= SSOFlag.SSO_FLAG_FIELD_INFO_MASK;
                }
                // create it
                ssoAdmin.CreateFieldInfo(appConfig.AppInfo.Name, field.Name, fieldFlags);
            }

            // enable application
            if (appConfig.AppInfo.Enabled == true)
            {
                ssoAdmin.UpdateApplication(appConfig.AppInfo.Name, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED);
            }
        }