Does a user have a specific encryption key attached to her ID file? Use this script function to find out.
The example displays a dialogbox showing if the current user owns encryption key "SampleKey". This could also be used to send an e-mail report on which users have a given key, or to set field values and display customized content based on whether or not the user owns the encryption key.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
'CALLING THE FUNCTION Sub Click(Source As Button) Const keyname = "SampleKey" If UserOwnsEncryptionKey(keyname) Then Msgbox "Key " & keyname & " is attached to your ID file." Else Msgbox "Key " & keyname & " is not attached to your ID file." End If End Sub 'FUNCTION ITSELF %INCLUDE "lserr.lss" Function UserOwnsEncryptionKey(keyname As String) 'Error 4000 occurs when calling testdoc.Encrypt if the user does not have the key whose name is passed to the function On Error 4000 Goto processError Dim ss As New NotesSession Dim db As NotesDatabase Dim testdoc As NotesDocument Dim item1 As NotesItem Set db = ss.CurrentDatabase Set testdoc = New NotesDocument(db) Set item1 = testdoc.AppendItemValue( "Test", "abc" ) item1.IsEncrypted = True testdoc.EncryptionKeys = keyname Call testdoc.Encrypt UserOwnsEncryptionKey = True Exit Function processError: UserOwnsEncryptionKey = False Exit Function End Function