DAFTools "How To..."
(Limited documentation for web sites on web hosting server.)
Retrieve information on the current user
DAF creates several server variables usable by any CGI or ASP script language:
For example, in an ASP script, you can retrieve a variable with the following line:
---------------------------------------------------------------------
The current web user is <%= Request.ServerVariables("HTTP_DAFLOGIN") %>
---------------------------------------------------------------------
Add a user to a DAF users list
The following ASP script will add a user to the user list attached to the current IP address:
<%
'------------------------------------------------------
'--- New User Information : ---
DAFLOGIN = "phil2"
DAFPASSWORD = "pass"
NTLOGIN = "john"
NTPASSWORD = "goodboy"
DAFGROUPS = "grp1;grp2;"
EXPIRATIONDATE = "1999-05-26"
'--- Database administration password
DBPASSWORD = "test"
'------------------------------------------------------
Set DafTools = Server.CreateObject("dafinfo.dafinfo.1")
set DB = DafTools.CurrentDB
DBName = DB.name
'--- login to DAFTools
if DafTools.LevelLogin(DBName,"Level3",DBPASSWORD) = FALSE then
'-- Can't log In, the password is probably invalid
response.write "NOT Logged <br>"
else
'--- We are logged, we can add the user
Result = DB.AddUser(DAFLOGIN, DAFPASSWORD,NTLOGIN, NTPASSWORD, DAFGROUPS,EXPIRATIONDATE)
if DafTools.Error.Code = 0 then
response.write "User was added <br>"
else
response.write "Error : " & DafTools.Error.Msg & "<br>"
DafTools.ClearError
end if
'--- We logoff ---
DafTools.LevelLogOff
end if
%>
See also: method AddUser of DB object.
Remove a DAF user from a users list
The following ASP script will add a remove user "phil" from the user list attached to the current IP address:
<%
'------------------------------------------------------
'--- User to remove
DAFLOGIN = "phil"
'--- Database administration password
DBPASSWORD = "test"
'------------------------------------------------------
Set DafTools = Server.CreateObject("dafinfo.dafinfo.1")
set DB = DafTools.CurrentDB
DBName = DB.name
'--- login to DAFTools
if DafTools.LevelLogin(DBName,"Level3",DBPASSWORD) = FALSE then
'-- Can't log In, the password is probably invalid
response.write "NOT Logged <br>"
else
'--- We are logged, we can remove the user
Result = DB.RemoveUser(DAFLOGIN)
if DafTools.Error.Code = 0 then
response.write "User was removed <br>"
else
response.write "Error : " & DafTools.Error.Msg & "<br>"
DafTools.ClearError
end if
'--- We logoff ---
DafTools.LevelLogOff
end if
%>
See also: method RemoveUser of DB object.
Modify a DAF user from a users list
The following ASP script will modify user "phil" from the user list attached to the current IP address:
<%
'------------------------------------------------------
'--- User to modify
DAFLOGIN = "phil"
'--- New user information
DAFPASSWORD = "pass"
NTLOGIN = "john"
NTPASSWORD = "goodboy"
DAFGROUPS = "grp1;grp2;"
EXPIRATIONDATE = "1999-05-26"
'--- Database administration password
DBPASSWORD = "test"
'------------------------------------------------------
Set DafTools = Server.CreateObject("dafinfo.dafinfo.1")
set DB = DafTools.CurrentDB
DBName = DB.name
'--- login to DAFTools
if DafTools.LevelLogin(DBName,"Level3",DBPASSWORD) = FALSE then
'-- Can't log In, the password is probably invalid
response.write "NOT Logged <br>"
else
'--- We are logged, we can modify the user
Result = DB.ModifyUser(DAFLOGIN, DAFPASSWORD,NTLOGIN, NTPASSWORD, DAFGROUPS,EXPIRATIONDATE)
if DafTools.Error.Code = 0 then
response.write "User was modified <br>"
else
response.write "Error : " & DafTools.Error.Msg & "<br>"
DafTools.ClearError
end if
'--- We logoff ---
DafTools.LevelLogOff
end if
%>
See also: method ModifyUser of DB object.
Change a Password of a DAF user
The following ASP script will change password of user "phil" from the user list attached to the current IP address:
<%
Set DafTools = Server.CreateObject("dafinfo.dafinfo.1")
Set DB = DafTools.CurrentDB
Result = DB.ChangePassword("phil", "pass", "newpass")
if DafTools.Error.Code = 0 then
response.write "Password was changed <br>"
else
response.write "Error : " & DafTools.Error.Msg & "<br>"
DafTools.ClearError
end if
%>
Remark:
With method ChangeUser it is not required to login because the old password is required to set the new password.
See also: method ChangeUser of DB object.
Find a DAF user in a users list
Two methods of DB object are available:
Sample with method FindUser:
<%
'------------------------------------------------------
'--- User to find
DAFLOGIN = "phil"
DAFPASSWORD = "pass"
'--- Database administration password
DBPASSWORD = "test"
'------------------------------------------------------
Set DafTools = Server.CreateObject("dafinfo.dafinfo.1")
set DB = DafTools.CurrentDB
DBName = DB.name
'--- login to DAFTools
if DafTools.LevelLogin(DBName,"Level3",DBPASSWORD) = FALSE then
'-- Can't log In, the password is probably invalid
response.write "NOT Logged <br>"
else
'--- We are logged, we search the user
'--- Note that with method FindUser the password is required
Set User = DB.FindUser(DAFLOGIN,DAFPASSWORD)
if DafTools.Error.Code <> 0 then
response.write "Error : " & DafTools.Error.Msg & "<br>"
DafTools.ClearError
else
response.write "DAF Login : " & User.daflogin & "<br>"
response.write "DAF Password : " & User.dafpassword & "<br>"
response.write "DAF Groups : " & User.dafgroups & "<br>"
response.write "NT Login : " & User.ntlogin & "<br>"
response.write "NT Password : " & User.ntpassword & "<br>"
response.write "ExpirationDate : " & User.ExpirationDate & "<br>"
response.write "DateLastVisit : " & User.DateLastVisit & "<br>"
response.write "NumberOfVisit : " & User.NumberOfVisit & "<br>"
end if
'--- We logoff ---
DafTools.LevelLogOff
end if
%>
Sample with method FindUser2:
<%
'------------------------------------------------------
'--- User to find
DAFLOGIN = "phil"
'--- Database administration password
DBPASSWORD = "test"
'------------------------------------------------------
Set DafTools = Server.CreateObject("dafinfo.dafinfo.1")
set DB = DafTools.CurrentDB
DBName = DB.name
'--- login to DAFTools
if DafTools.LevelLogin(DBName,"Level3",DBPASSWORD) = FALSE then
'-- Can't log In, the password is probably invalid
response.write "NOT Logged <br>"
else
'--- We are logged, we search the user
'--- Note that with method FindUser2 the password isn't required
Set User = DB.FindUser2(DAFLOGIN)
if DafTools.Error.Code <> 0 then
response.write "Error : " & DafTools.Error.Msg & "<br>"
DafTools.ClearError
else
response.write "DAF Login : " & User.daflogin & "<br>"
response.write "DAF Password : " & User.dafpassword & "<br>"
response.write "DAF Groups : " & User.dafgroups & "<br>"
response.write "NT Login : " & User.ntlogin & "<br>"
response.write "NT Password : " & User.ntpassword & "<br>"
response.write "ExpirationDate : " & User.ExpirationDate & "<br>"
response.write "DateLastVisit : " & User.DateLastVisit & "<br>"
response.write "NumberOfVisit : " & User.NumberOfVisit & "<br>"
end if
'--- We logoff ---
DafTools.LevelLogOff
end if
%>
The last error is stored in DAFTools "Error object," which can be reset with method "ClearError."
It is handy to use the following ASP sub-routine to display any DAFTools error. For example:
Set DafTools =
Server.CreateObject("dafinfo.dafinfo.1")
.
.
Set DB = DafTools.CurrentDB
call DAFError()
.
Set User = DB.FindUser("phil","pass")
call DAFError()
Sub DAFError()
if DafTools.Error.Code <> 0 then
response.write "Error Msg : " & DafTools.Error.Msg & "<br>"
response.write "Error Code : " & DafTools.Error.Code & "<br>"
response.write "Error Object : " & DafTools.Error.Object & "<br>"
DafTools.ClearError
end if
end sub