ManagementUserInfo 类

定义

封装有关 IIS 管理器用户的信息。

public ref class ManagementUserInfo
public class ManagementUserInfo
type ManagementUserInfo = class
Public Class ManagementUserInfo
继承
ManagementUserInfo

示例

以下示例获取 对象的集合 ManagementUserInfo ,并显示集合中每个元素的属性值。 该示例将用户添加到 IIS 管理器用户列表中(如果该用户还不是成员)。

// Returns a Property bag that contains the Site Owner Details.
public PropertyBag GetSiteOwnerDetails(string siteName)
{
    PropertyBag SiteOwnerDetailsBag = new PropertyBag();

    AppDomain domain = Thread.GetDomain();
    domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
    WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;

    // Gets the site from the siteName.
    Site site = base.ManagementUnit.ServerManager.Sites[siteName];
    // Set the path.
    string path = site.Name;
    SiteOwnerDetailsBag.Add(0, principal.Identity.Name);
    SiteOwnerDetailsBag.Add(1, 
        principal.IsInRole(WindowsBuiltInRole.Administrator).ToString());
    SiteOwnerDetailsBag.Add(2, siteName as string);
    // Create a new ManagementUser.
    string managementusername = "SuperManager";
    string managementuserpassword = "password";
    string message = null;
    string display = null;
    ManagementUserInfoCollection managementUserInfoCollection = 
        ManagementAuthentication.GetUsers(0, -1);
    message = "\nUsers count: " + managementUserInfoCollection.Count.ToString();
    display = display + message;
    bool isInCollection = false;
    message = null;
    foreach (ManagementUserInfo userInfo in managementUserInfoCollection)
    {
        message = message + "\nName: " + userInfo.Name;
        message = message + "     Enabled: " + userInfo.Enabled;
        message = message + "     ToString: " + userInfo.ToString();
        // Check to see if the management user is already in the collection.
        if (managementusername.Equals(userInfo.Name))
        {
            isInCollection = true;
        }
    }
    // Add the manager user if not already in the collection.
    if (!isInCollection)
    {
        ManagementUserInfo newManagementUser = 
            ManagementAuthentication.CreateUser(
            managementusername, managementuserpassword);
        message = message + "\nadded: " + managementusername;
    }
    display = display + message;
    SiteOwnerDetailsBag.Add(3, display as string);
    return SiteOwnerDetailsBag;
}

注解

此类提供用于管理服务器上的 IIS 管理器用户的功能。

可以将服务器配置为允许具有 Windows 凭据的帐户中的 IIS 管理器用户执行管理服务。 IIS 管理器的“IIS 管理器用户 ”页上提供了授权用户列表。 Administration.config文件中也提供了该列表。 IIS 管理器用户在服务器级别被授予权限,不限于特定站点或应用程序。

构造函数

ManagementUserInfo(String, Boolean)

初始化 ManagementUserInfo 类的新实例。

属性

Enabled

获取一个值,该值指示 IIS 管理器用户是否可以在 IIS 管理器中执行管理服务。

Name

获取 IIS 管理器用户的名称。

方法

ToString()

返回 IIS 管理器用户的名称。

适用于