> developer > dnu > courses > Web Services

Microsoft's IIS Web Server

Reader Rating    from ratings rate this article
View an eBook Version of this course - LARGE FILE! Send this page to a friend

This section describes how to enable authentication against a Directory Service utilizion Microsoft's IIS Web Server.

Sample Code

Aspverif.exe is sample code which demonstrates how to use Novell's ActiveX controls NWDir and NWSess in Microsoft's ASP environment. The code shows how, using ActiveX controls, remote users can be verified against their objectID/password pairs in eDirectory (http://developer.novell.com/support/sample/tids/aspverif/).

Description

This project consists of three files: global.asa, aspverify.asp, and verify.asp.

Global.asa is used to create instances of application objects for NWDir and NWSess controls and for creating authenticated service connection to the eDirectory. Login information, needed for this service connection, is hard-coded into the file, which keeps the code simple. Service connection is created only once and remains valid until the application has finished.


<OBJECT RUNAT=server SCOPE=Application ID=nwdir PROGID="NWDirLib.NWDirCtrl.1">
</OBJECT>
<OBJECT RUNAT=server SCOPE=Application ID=nwsess
PROGID="NWSessLib.NWSessCtrl.1">
</OBJECT>

<SCRIPT LANGUAGE=vbscript RUNAT=server>

SUB Application_OnStart
call nwsess.login("NDS:\\TREE_NAME\CONTEXT","USER_NAME","PASSWORD",FALSE)
nwdir.FullName="NDS:\\TREE_NAME\[Root]"
set Application("nwsess1")=nwsess
set Application("nwdir1") =nwdir
END SUB

SUB Application_OnEnd
call nwsess.logout("NDS:\\TREE_NAME\CONTEXT\USER_NAME")
set nwsess1=nothing
set nwdir1=nothing
END SUB

SUB Session_OnStart
END SUB

SUB Session_OnEnd
END SUB

</script>

ASPVerify.asp is the main page of the application. In this case it is used only for getting input data from the user--fully qualified DS name for a given object and a password.


<!--
================================================================
Copyright ® 1999 Novell, Inc. All Rights Reserved.

With respect to this file, Novell hereby grants to Developer a
royalty-free, non-exclusive license to include this sample code
and derivative binaries in its product. Novell grants to Developer
worldwide distribution rights to market, distribute or sell this
sample code file and derivative binaries as a component of
Developer 's product(s). Novell shall have no obligations to
Developer or Developer's customers with respect to this code.

DISCLAIMER:

Novell disclaims and excludes any and all express, implied, and
statutory warranties, including, without limitation, warranties
of good title, warranties against infringement, and the implied
warranties of merchantibility and fitness for a particular purpose.
Novell does not warrant that the software will satisfy customer's
requirements or that the licensed works are without defect or error
or that the operation of the software will be uninterrupted.
Novell makes no warranties respecting any technical services or
support tools provided under the agreement, and disclaims all other
warranties, including the implied warranties of merchantability and
fitness for a particular purpose.

================================================================
Project: ASPVerify

Desc:
Sample code which demonstrates how to use Novell`s ActiveX
controls NWDir and NWSess in Microsoft`s ASP environment.
The code shows how - using ActiveX controls - remote users
can be verified against their objectID/password pairs in NDS.

This project consists of three files: global.asa, aspverify.asp
and verify.asp.

Global.asa is used to create instances of application objects
for NWDir and NWSess controls and for creating authenticated service
connection to the NDS. Login information, needed for this service
connection, is hard-coded into the file, which keeps the code simple.
Service connection is created only once and remains valid until
the application has finished.

ASPVerify.asp is the main/first page of the application. In our case
it is used only for getting input data from the user - fully qualified DS name
for a given object and a password.

Verify.asp processes the data using global service connection created in
global.asa. First 'UNC-like' name must be assembled, i.e. translation from
"user.cont1.cont2" formatto "NDS:\\TREE_NAME\CONT2\CONT1\USER" format must take
place. Next user is found in NDS by issuing nwdir.FindEntry method().
Last user's password is verified by calling nwdir.ValidatePassword() method.

We have to point out here, that by default for such tasks like password
verification, there is no need to be authenticated into NDS with special service
connection,when using nwdir.validatePassword() method. This method can be
sucessfuly called with [Public] only trustee assignment (which is default
for any not-authenticated object).

Service authentication code, we added to global.asa, can be used to
accomplish other, more complicated tasks.
Programmers:

Ini Who Firm
------------------------------------------------------------------
RLE Rostislav Letos Novell Developer Support.

History:

When Who What
------------------------------------------------------------------
November 1999 RLE Initial code


=====================================================================
-->
<%@ Language=VBScript %>
<html>
<head>
<title> Novell ActiveX/ASP sample - Password verification </title>
</head>
<body>
<br>
<font face="Arial" size="+1" color="Red">Novell ActiveX/ASP
sample - Password verification</font>
<br><br>
<form ACTION=verify.asp METHOD="GET">
<table>
<tr>
<td ALIGN="right">User full name:</td>
<td><input type="Text" name="userName"></td>
</tr>
<tr>
<td ALIGN="right">Password:</td>
<td><input type="Password" name="password"></td>
</tr>
<tr>
<td></td>
<td>
<input type="Submit" name="LoginButton" value="Verify">
<input type="reset">
</td>
</tr>
</table>
</form>

</body>
</HTML>

Verify.asp processes the data using global service connection created in global.asa. First `UNC-like' name must be assembled, i.e. translation from user.cont1.cont2 format to NDS:\\TREE_NAME\CONT2\CONT1\USER format must take place. Next user is found in eDirectory by issuing nwdir.FindEntry method(). Last user's password is verified by calling nwdir.ValidatePassword() method.


<!--
================================================================
Copyright ® 1999 Novell, Inc. All Rights Reserved.

With respect to this file, Novell hereby grants to Developer a
royalty-free, non-exclusive license to include this sample code
and derivative binaries in its product. Novell grants to Developer
worldwide distribution rights to market, distribute or sell this
sample code file and derivative binaries as a component of
Developer 's product(s). Novell shall have no obligations to
Developer or Developer's customers with respect to this code.

DISCLAIMER:

Novell disclaims and excludes any and all express, implied, and
statutory warranties, including, without limitation, warranties
of good title, warranties against infringement, and the implied
warranties of merchantibility and fitness for a particular purpose.
Novell does not warrant that the software will satisfy customer's
requirements or that the licensed works are without defect or error
or that the operation of the software will be uninterrupted.
Novell makes no warranties respecting any technical services or
support tools provided under the agreement, and disclaims all other
warranties, including the implied warranties of merchantability and
fitness for a particular purpose.

================================================================
Project: ASPVerify

Desc:
Sample code which demonstrates how to use Novell`s ActiveX
controls NWDir and NWSess in Microsoft`s ASP environment.
The code shows how - using ActiveX controls - remote users
can be verified against their objectID/password pairs in NDS.

This project consists of three files: global.asa, aspverify.asp
and verify.asp.

Global.asa is used to create instances of application objects
for NWDir and NWSess controls and for creating authenticated service
connection to the NDS. Login information, needed for this service
connection, is hard-coded into the file, which keeps the code simple.
Service connection is created only once and remains valid until
the application has finished.

ASPVerify.asp is the main/first page of the application. In our case
it is used only for getting input data from the user - fully qualified DS name
for a given object and a password.

Verify.asp processes the data using global service connection created in
global.asa. First 'UNC-like' name must be assembled, i.e. translation from
"user.cont1.cont2" format to "NDS:\\TREE_NAME\CONT2\CONT1\USER" format
must take place. Next user is found in NDS by issuing nwdir.FindEntry
method(). Last user's password is verified by calling
nwdir.ValidatePassword() method.

We have to point out here, that by default for such tasks like
password verification, there is no need to be authenticated into NDS
with special service connection, when using nwdir.validatePassword()
method. This method can be sucessfuly called with [Public] only
trustee assignment (which is default for any not-authenticated object).

Service authentication code, we added to global.asa,
can be used to accomplish other, more complicated tasks.


Programmers:

Ini Who Firm
------------------------------------------------------------------
RLE Rostislav Letos Novell Developer Support.

History:

When Who What
------------------------------------------------------------------
November 1999 RLE Initial code


=====================================================================
-->

<%@ Language=VBScript %>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub VerifyPassword
dim nwdir, retcode, entry
dim treeName, userName, password, ndsName

set nwdir=Application("nwdir1")
userName=Request.QueryString("userName")
on error resume next
ndsName= nwdir.TreeFromFullName(nwdir.LoginName)
ndsName= nwdir.FullNameFromTreeAndContext(ndsName,userName)
response.write "Object " & ndsName & "<br>"
set entry=nwdir.findEntry(ndsName)
if entry is nothing then
response.write "Error " & str(err.number) & ", " & err.description &
"<br>"
response.write "Object not found !" & "<BR>"
else
password=Request.QueryString("password")
retcode=entry.ValidatePassword(password)
if retcode=TRUE then
response.write("<BR> Password is valid !")
else
response.write("<BR> Password is NOT valid !")
end if
end if
end sub

</SCRIPT>

<html>
<head>
<title> Novell ActiveX/ASP sample - Password verification </title>
</head>
<body>
<br>
<font face="Arial" size="+1" color="Red">Novell ActiveX/ASP sample -
Password verification</font>
<br><br>
<% VerifyPassword %>
</body>
</HTML>

Be aware that by default for such tasks like password verification, there is no need to be authenticated into eDirectoryeDirectory with special service connection, when using nwdir.validatePassword() method. This method can be sucessfuly called with [Public] only trustee assignment (which is default for any not-authenticated object). Service authentication code, we added to global.asa, can be used to accomplish other, more complicated tasks.



Previous blank Table of Contents blank Next