IAuthenticationModuleService.IsEnabled 方法

定义

确定是否启用指定的身份验证模块服务。

public:
 bool IsEnabled();
public bool IsEnabled ();
abstract member IsEnabled : unit -> bool
Public Function IsEnabled () As Boolean

返回

trueIAuthenticationModuleService如果接口已启用,则为 ;否则为 false

示例

以下示例检查 Administration.config 文件中定义的身份验证模块服务,并显示 IsEnabled 方法返回值。

namespace ExtensibilityDemo
{
    public class DemoModuleService : ModuleService
    {
        [ModuleServiceMethod]
        public ArrayList GetSettings()
        {
            ArrayList settingList = new ArrayList();
            ServerManager manager = new ServerManager();
            ConfigurationElementCollection serverCollection;
            Configuration config = manager.GetAdministrationConfiguration();
            ConfigurationSection section = config.GetSection("moduleProviders");
            serverCollection = section.GetCollection();
            IAuthenticationModuleService authenticationModuleService;
            // Get all of the modules on the server. Filter the modules
            // to those of the IAuthenticationModuleService type.
            foreach (ConfigurationElement configurationElement in serverCollection)
            {
                // Add the authentication module service and the returned
                // IsEnabled value to the property bag for subsequent display.
                try
                {
                    // If the module service is other than an
                    // IAuthenticationModuleService an exception is thrown.
                    authenticationModuleService = (IAuthenticationModuleService)
                        ManagementUnit.GetModuleService(configurationElement.Attributes[0].Value.ToString());
                    PropertyBag settingBag = new PropertyBag();
                    settingBag[0] = authenticationModuleService.ToString();
                    settingBag[1] = authenticationModuleService.IsEnabled().ToString();
                    settingList.Add(settingBag);
                }
                catch
                {
                }
            }
            return settingList;
        }
    }
}

注解

可以使用此方法来确定站点上使用的身份验证模块服务。

适用于