Let us say that you have an HTML page on the server with links to various databases within your Intranet. Users login to the server using basic browser authentication to a database called home.nsf. One of the databases is restricted to a group of users. So, you do not really want the other users to see the link. The HTML pages on the server are managed by users via FTP (they have no access to a Domino designer client). So how do we accomplish the hide-when?
The answer is simple:
Create a LotusScript agent in the home.nsf DB called checkUser.js and set it to run as web user. The agent checks the users' group details using an @userNamesList function and then prints a JavaScript function called writeLink(). This will write the link.
Next, in your HTML file (<Head> section) reference the agent as an include for JavaScript: <script language='javascript' src='/domino/intranet/home.nsf/checkUser.js'> </script> The browser thinks it is just a JavaScript text module.
In your HTML file, place a call to the writeLink() function in the place that you want your link to be written.
LotusScript Agent in Home.nsf DB (run a web user)
Sub Initialize
Dim temp As Variant
Const GROUP = "BookingAdmin"
'Grab a list of groups that the web user belongs to - implode them into
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
'tells Domino to send the results as plain text only (no HTML tags) Print "Content-type:text/plain"
'start creating the function Print "function writeLink(){"
'check to see if the list contains the group If Instr("" & temp(0), GROUP) > 0 Then 'the user is in the group then create WRITE command Print "document.write('Click here to access the <a href=" + Chr$(34) + "CBookingV2.nsf/frmFirst?OpenForm" + "" + Chr$(34) +">Booking System</a>" + "');"
End If
'close the JavaScript function Print "}"
End Sub
HTML Page:
<HTML> <HEAD> <TITLE>Test Links</TITLE> <script language='javascript' src='/domino/intranet/home.nsf/checkUser.js'> </script> </HEAD> <BODY BGCOLOR="white">
<!-- call to javaScript function --> <p><font face="arial"> <script language="javascript"> writeLink(); </script>
</BODY> </HTML>
This was first published in May 2001