2 — Getting Started


[Previous] [Next] [Contents] [Index]


This chapter describes how to create applications that use the Authorization Object. It includes the following sections:

2.1 Creating Applications
2.2 Creating and Initializing the Object
2.3 Using the Object in Applications

2.1 Creating Applications

To create applications that use the Authorization Object, you use ASP (Active Server Pages).

The following pages give an overview of the necessary steps. For a complete description of the function calls, see Chapter 3.

2.2 Creating and Initializing the Object

You must create and optionally initialize the Authorization Object before you can use it.

NOTE: The following examples use VBScript. If you are using a different scripting language, use the appropriate commands for that language.

To create an object:

  1. Create a variable for an instance of NetCAuth and create the object:

    Dim myObj
    

  2. Create the object:

    set myObj = Server.CreateObject ("NetCAuth.NetCObj.1")
    

    In this statement, NetCAuth is the name of the DLL. NetCObj.1 is the registered ProgID in the Window NT registry of the Authorization Object, and is needed to create the object.

If you are going to use the CheckAccess or GetPermissions methods, you must also initialize the object.

myObj.InitModel "mibank", "/", 0

In this statement:

mibank refers to the module name, and is the same name used to name the model file. (Model files are described in Chapter 4.)

"/" indicates that the model applies starting at the root.

"0" indicates that Traverse permission does not apply. (For a complete description of the InitModel call, see the Reference section later in this document.)

2.2.1 Object Scope

If you want to use the Authorization Object on a single page, you can create the object on that page and the object will be deleted when it goes out of scope (when the script terminates).

2.2.2 Sharing the Object Across Application Pages

If you want to share the Authorization Object across application pages, you can set it as a Session object and refer to it in other pages.

For example:

For more examples of using the Session object, see the sample code in the samples subdirectory of the NetCrusader/Web installation directory.

2.3 Using the Object in Applications

The following sections give an overview of some of the uses for the Authorization Object. Samples of most of these uses are included in the samples subdirectory of the NetCrusader/Web installation directory.

NOTE: The samples use VBScript, but you are not limited to using VBScript in your applications.

2.3.1 Forms-Based Logon

With the Authorization Object, you can use an HTML form to log a user in and authenticate that user. For example, the following illustration shows a very simple HTML form that is created when you run the sample logon.htm.


The form is a standard HTML form that uses the following FORM tag:

<form name=enterData action=logon.asp method=post>

Note that the method is POST and the argument for the ACTION attribute is the name of the ASP file that contains the code that uses the Authorization Object.

The logon.asp file:

  1. Creates and initializes a NetCrusader/Web Authorization Object:

    dim netc 
    set netc = Server.CreateObject("NetCAuth.NetCObj.1")
    netc.InitModel "simple", "/", 0
    

  2. Gets the name and password from the form:

    formName    = Request.Form("opName")
    formPassword = Request.Form("opPwd")
    

  3. Authenticates the user:

    netc.Authenticate formName, formPassword
    

2.3.2 Logging Users Off

Logging off using the Authorization Object is very simple, as illustrated in the logoff.asp sample. The logoff.asp file logs the user out:

netc.LogOff

2.3.3 Web Single Sign On

The sample singlesignon.asp is similar to the logon.asp sample with an important difference. In singlesignon.asp, the user does not provide a name and password. Instead, SingleSignOn uses the cookie contents to look up and validate an existing session.

netc.SingleSignOn

2.3.4 Obtaining Users' Permissions

The file netcCOMAuthz.asp shows an example of how to determine what permissions a user has for an object. For example:

Response.Write netc.GetPermissions ("/obj1")

This displays the permissions the user has for obj1 (Obj1 is an object defined in the simple model.)

2.3.5 Getting a User's Attributes

The sample comtest.asp shows an example of how to obtain users' attributes. For example:

  1. Get the user name:

    dim uname
    uname = netc.getPrincipal
    Response.write uname
    

  2. Get a custom attribute:

    Response.write netc.GetNameValue(uname, "myCustomAttr")
    

2.3.6 Performing User Management Tasks

After you have logged a user on (authenticated the user), you can perform a number of user management tasks in your application, as illustrated in comtest.asp:

For more information, see comtest.asp, which shows examples of every function described in Chapter 3.


[Previous] [Next] [Contents] [Index]


To make comments or ask for help, contact support@entegrity.com.

Copyright © 2000-2002 Entegrity Solutions Corporation & its subsidiaries