Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

AuthenticationServiceManager Class

Configures the location of a custom implementation of the authentication service.

Syntax

CSharp

[DefaultPropertyAttribute("Path")]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AuthenticationServiceManager

VisualBasic

<DefaultPropertyAttribute("Path")> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class AuthenticationServiceManager

ManagedCPlusPlus

[DefaultPropertyAttribute(L"Path")]
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class AuthenticationServiceManager

JSharp

/** @attribute DefaultPropertyAttribute("Path") */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public class AuthenticationServiceManager

Members

IconMemberDescription
AuthenticationServiceManagerNew()Initializes a new instance of the AuthenticationServiceManager class.
Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Finalize()Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
GetHashCode()Serves as a hash function for a particular type. (Inherited from Object.)
GetType()Gets the Type of the current instance. (Inherited from Object.)
MemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
PathGets or sets the path of the authentication service.
ToString()Returns a String that represents the current Object. (Inherited from Object.)

Remarks

The AuthenticationServiceManager class corresponds to the AuthenticationService property of the ScriptManager or ScriptManagerProxy control.

The authentication Web service is used by Microsoft ASP.NET 2.0 AJAX Extensions applications to log on and log off from client script. You can use AuthenticationServiceManager to provide the path of an alternative implementation of the authentication Web service instead of using the built-in Web service that is provided by ASP.NET 2.0 AJAX Extensions.

To use the authentication service in your application, you must enable it in the configuration file. If you use the built-in authentication Web service, you do not have to explicitly declare the authentication service manager on the page.

To create your own authentication service, you must implement a Web service that has two methods: Login and Logout. In addition, these methods require the same signature of the built-in authentication Web service.

The following example shows the basic class structure that must be implemented in a custom authentication Web service class.

CS

<%@ WebService Language="C#" Class="MyAuthenticationService" %>

using System.Web.Services;
using System.Web.Script.Services;

[ScriptService]
public class MyAuthenticationService  : System.Web.Services.WebService 
{
    [WebMethod]
    public bool Login(string userName, 
        string password, bool createPersistentCookie)
    {
        //Place code here.
        return true;
    }

    [WebMethod]
    public void Logout()
    {
        //Place code here.
    }  
}

VB

<%@ WebService Language="VB" Class="MyAuthenticationService" %>

Imports System.Web.Services
Imports System.Web.Script.Services

<ScriptService()> _
Public Class MyAuthenticationService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function Login(ByVal userName As String, _
        ByVal password As String, _
        ByVal createPersistentCookie As Boolean) As Boolean

        'Place code here.
        Return True

    End Function

    <WebMethod()> _
    Public Sub Logout()

        'Place code here.

    End Sub

End Class

To use a custom authentication Web service, you can add the service declaratively in markup by including an <AuthenticationService> element inside the <asp:ScriptManager> element on the page, as shown in the following example.

<asp:ScriptManager ID="SM1" runat="server">
  <AuthenticationService Path="MyAuthenticationService.asmx" />
</asp:ScriptManager>

You can also programmatically configure Path to use a custom authentication Web service.

Regardless of whether the declarative section for the authentication service is on the page, if the authentication service is enabled in the configuration file, then ASP.NET 2.0 AJAX Extensions will include an ECMAScript (JavaScript) variable in the rendered page. This allows client script to determine whether the current user is authenticated.

Permissions

  • AspNetHostingPermission

    for operating in a hosted environment. Demand value: LinkDemand. Associated enumeration: Minimal.

  • AspNetHostingPermission

    for operating in a hosted environment. Demand value: InheritanceDemand. Associated enumeration: Minimal.

Inheritance Hierarchy

Object

  • AuthenticationServiceManager

Assembly: System.Web.Extensions (Module: System.Web.Extensions)