Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ManagementUserInfo Class

IIS 7.0

Encapsulates information about an IIS Manager user.

System..::..Object
  Microsoft.Web.Management.Server..::..ManagementUserInfo

Namespace:  Microsoft.Web.Management.Server
Assembly:  Microsoft.Web.Management (in Microsoft.Web.Management.dll)
public class ManagementUserInfo

The ManagementUserInfo type exposes the following members.

  NameDescription
Public methodManagementUserInfoInitializes a new instance of the ManagementUserInfo class.
Top
  NameDescription
Public propertyEnabledGets a value indicating whether the IIS Manager user can perform management services in IIS Manager. 
Public propertyNameGets the name of the IIS Manager user. 
Top
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToStringReturns the name of the IIS Manager user. (Overrides Object..::..ToString()()()().)
Top

This class provides functionality for managing IIS Manager users on the server.

You can configure the server to allow IIS Manager users, from accounts with Windows credentials, to perform management services. A list of authorized users is available on the IIS Manager Users page of IIS Manager. The list is also available in the Administration.config file. IIS Manager users are granted permissions at the server level and are not limited to a specific site or application.

The following example obtains a collection of ManagementUserInfo objects and displays the property values for each element of the collection. The example adds a user to the list of IIS Manager users if the user is not already a member.

// 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;
}


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.