Adding a Domino hide-when to a HTML file

Adding a Domino hide-when to a HTML file

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.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

a string     temp = Evaluate("@implode(@userNamesList; " & Chr$(34) & "<br>" & Chr$(34) & ")")

   

'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

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.