AuthenticationSection Class [IIS 7 and higher]

IIS 7.0

Configures ASP.NET authentication.

class AuthenticationSection : ConfigurationSectionWithCollection

The following table lists the methods exposed by the AuthenticationSection class.

Name

Description

Add

(Inherited from ConfigurationSectionWithCollection.)

Clear

(Inherited from ConfigurationSectionWithCollection.)

Get

(Inherited from ConfigurationSectionWithCollection.)

GetAllowDefinition

(Inherited from ConfigurationSection.)

GetAllowLocation

(Inherited from ConfigurationSection.)

Remove

(Inherited from ConfigurationSectionWithCollection.)

RevertToParent

(Inherited from ConfigurationSection.)

SetAllowDefinition

(Inherited from ConfigurationSection.)

SetAllowLocation

(Inherited from ConfigurationSection.)

The following table lists the properties exposed by the AuthenticationSection class.

Name

Description

Forms

A FormsAuthenticationConfiguration value that configures Forms authentication for the Web application.

Location

(Inherited from ConfigurationSection.) A key property.

Mode

A read/write sint32 value that specifies the authentication mode for the Web application. The possible values are listed later in the Remarks section.

Passport

A PassportAuthentication value that contains a URL to which the authentication request will be redirected.

Path

(Inherited from ConfigurationSection.) A key property.

SectionInformation

(Inherited from ConfigurationSection.)

This class contains no subclasses.

The following table lists the possible values for the Mode property. The default is 1 (Windows).

Value

Keyword

Description

0

None

Specifies no authentication. 

1

Windows

Specifies Windows as the authentication mode. This mode applies when ASP.NET uses the Basic, Digest, Integrated Windows (NTLM/Kerberos), or Client Certificate Mapping authentication methods. 

2

Passport

Specifies Microsoft Passport Network authentication as the authentication mode.

3

Forms

Specifies ASP.NET Forms authentication as the authentication mode.

The following example displays the authentication mode for the default Web site. If the authentication mode is Passport, the redirect URL is displayed. If the mode is Forms, the corresponding information is displayed.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = _
    GetObject("winmgmts:root\WebAdministration")

' Get the authentication section.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "AuthenticationSection", oAuthSection

' Display the path and location.
WScript.Echo "Path: " & oAuthSection.Path
WScript.Echo "Location: " & oAuthSection.Location
WScript.Echo 

' Get the authentication mode and display it in text.
strAuthMode = ModeText(oAuthSection.Mode)
WScript.Echo "Authentication Mode: " &  _
    "[ " & strAuthMode & " ]"

' If the mode is Passport or Forms, display the 
' additional information.
If strAuthMode = "Passport" Then

    WScript.Echo "Passport URL: " & "[" & _
        oAuthSection.Passport.RedirectUrl & "]"

ElseIf strAuthMode = "Forms" then

    DisplayFormsAuthSettings(oAuthSection.Forms)

End If

' Convert the Mode enumeration values to text.
Function ModeText(enumValue)
    Select Case enumValue
        Case 0
            ModeText = "None"
        Case 1
            ModeText = "Windows"
        Case 2
            ModeText = "Passport"
        Case 3
            ModeText = "Forms"
        Case Else
            ModeText = "Undefined enumeration value."
    End Select
End Function

' Display the Forms authentication settings.
Sub DisplayFormsAuthSettings(oFormsAuthConfig)
    WScript.Echo vbCrLf & "Forms Authentication Settings"
    WScript.Echo "-----------------------------"

    WScript.Echo "Cookieless: [ " & _
        CookielessText(oFormsAuthConfig.Cookieless) & " ]"

    WScript.Echo "Default Url: [ " & _
        oFormsAuthConfig.DefaultUrl & " ]"

    WScript.Echo "Domain: [ " & _
        oFormsAuthConfig.Domain & " ]"

    WScript.Echo "EnableCrossAppRedirects: [" & _
        oFormsAuthConfig.EnableCrossAppRedirects & " ]"

    WScript.Echo "LoginUrl: [ " & _
        oFormsAuthConfig.LoginUrl & " ]"

    WScript.Echo "Name: [ " & _
        oFormsAuthConfig.Name & " ]"

    WScript.Echo "Path: [ " & _
        oFormsAuthConfig.Path & " ]"

    WScript.Echo "Protection: [ " & _
        ProtectionText(oFormsAuthConfig.Protection) & " ]"

    WScript.Echo "RequireSSL: [ " & _
        oFormsAuthConfig.RequireSSL & " ]"

    WScript.Echo "SlidingExpiration: [ " & _
        oFormsAuthConfig.SlidingExpiration & " ]"

    WScript.Echo "Timeout: [ " & _
        oFormsAuthConfig.Timeout & " ]"

    DisplayCredentials(oFormsAuthConfig.Credentials)

End Sub

' Convert the Cookieless enumeration values to text.
Function CookielessText(enumValue)
    Select Case enumValue
        Case 0
            CookielessText = "UseUri"
        Case 1
            CookielessText = "UseCookies"
        Case 2
            CookielessText = "AutoDetect"
        Case 3
            CookielessText = "UseDeviceProfile"
        Case Else
            CookielessText = "Undefined enumeration value."
    End Select
End Function

' Convert the Protection enumeration values to text.
Function ProtectionText(enumValue)
    Select Case enumValue
        Case 0
            ProtectionText = "All"
        Case 1
            ProtectionText = "None"
        Case 2
            ProtectionText = "Encryption"
        Case 3
            ProtectionText = "Validation"
        Case Else
            ProtectionText = "Undefined enumeration value."
    End Select
End Function

' Display the Forms authentication credentials.
Sub DisplayCredentials(FA_Credentials)
    WScript.Echo vbCrLf & "Forms Authentication Credentials"
    WScript.Echo "--------------------------------"
    WScript.Echo "Password Format: " & _
        PwdFormatText(FA_Credentials.PasswordFormat) & VbCrLf

    For Each FormsAuthUser In FA_Credentials.Credentials
        WScript.Echo "    Name: [ " & FormsAuthUser.Name & " ]"
        WScript.Echo "Password: [ " & _
            FormsAuthUser.Password& " ]"
        WScript.Echo
    Next
End Sub

' Convert the PasswordFormat enumeration values to text.
Function PwdFormatText(enumValue)
    Select Case enumValue
        Case 0
            PwdFormatText = "Clear"
        Case 1
            PwdFormatText = "SHA1"
        Case 2
            PwdFormatText = "MD5"
        Case Else
            PwdFormatText = "Undefined enumeration value."
    End Select
End Function

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

Community Additions

ADD
Show: