Is it really that hard to tell if a document is encrypted? Please help!
I am a bit frustrated. For a customer application I need to determine whether a document a user has selected in a view is encrypted or not. "Geez, now, that's easy", I hear you say. That's what I thought as well. Exactly for that purpose the NotesGod invented the NotesDocument.IsEncrypted method (I thought). Unfortunately either I am missing something blatantly obvious or the property just doesn't work properly.
I have tested several situations in several client versions and it seems that in one situation the NotesDocument.IsEncrypted method is not working as expected (tested in Notes 6.5.6, 7.0.2 and 8.0.1).
Scenario
A user has opened the Inbox folder of his/her mail file. The user starts a LotusScript agent (in my case using an action) which processes all selected documents and tries to determine which of the selected documents are encrypted. This is done using the UnprocessedDocuments property of the current database.
Error Description
If a document is encrypted for the current user using his/her public key (which usually is the case for encrypted mails in a user's mailbox) the NotesDocument.IsEncrypted method returns False for all documents, regardless of whether they actually are encrypted or not.
When I looked at an encrypted document in the Debugger I saw to my amazement that not only the IsEncrypted property was false but also the items $Seal and $SealData were missing from the items list of the document. When looking at the document's properties in the Inbox (or any other view) the $Seal and $SealData items are listed in the properties box.
If the agent is executed on a document which is encrypted for another user (e.g. me running the agent in the mail file of a test user) the property works as expected. If the document is open in the UI the property works as expected as well.
I have tried @IsAvailable($Seal) and that works but only in a real formula language agent. If used in an Evaluate statement in my LotusScript agent it returns false as well.
Using the IsEncrypted method of the Body item does not help either because it also returns true if a document is signed but not encrypted.
I have searched the forums, the knowledge base and the fix list database without finding any trace of somebody else having a problem with this.
If anybody has an idea what's wrong here I'd appreciate any help very much.
Sample Agents
To illustrate this here is a little sample agent which does nothing but display the value the IsEncrypted method returns for the first selected document.
Test agent to be run from a view or folder
This agent will return false when run from a view on a single encrypted document and true when run on an encrypted document which is open in the UI.
Update: This sample agent is nearly identical to the example provided in the Domino Designer 6.5 Help. So either the sample agent is incorrect or the property just doesn't work correctly.
Sub Initialize '-- Test using the first selected document in a view '-- Action Menu Selection - All selected documents Dim sess As New NotesSession Dim db As NotesDatabase Dim dc As NotesDocumentCollection Dim doc As NotesDocument Set db = sess.CurrentDatabase Set dc = db.UnprocessedDocuments Set doc = dc.GetFirstDocument Msgbox "NotesDocument.IsEncrypted: " + _ Cstr(doc.IsEncrypted), 0, "Using First Selected Doc in View" End Sub
Test agent for a document currently open in the UI
This agent will return the correct value when run on a document which is currently open in the UI.
Sub Initialize '-- Test using the currently open uidocument to retrieve the NotesDocument '-- Action Menu Selection - Target: None Dim uiws As New NotesUIWorkspace Dim uidoc As NotesUIDocument Dim doc As NotesDocument Set uidoc = uiws.CurrentDocument If Not uidoc Is Nothing Then Set doc = uidoc.Document Msgbox "NotesDocument.IsEncrypted: " + _ Cstr(doc.IsEncrypted), 0, "Using Currently Open UIDocument" End If End Sub










Comments
---* Bill
Posted by Wild Bill At 11:16:32 AM On 03/18/2008 | - Website - |
Posted by Jens Polster At 11:21:05 AM On 03/18/2008 | - Website - |
Running an agent from the Inbox folder I got:
Set item = doc.GetFirstItem( "Body" )
item.IsEncrypted = True
doc.IsEncrypted = False
Hope this helps.
Posted by Vitor Pereira At 03:14:12 PM On 03/18/2008 | - Website - |
Posted by Jens Polster At 04:17:24 PM On 03/18/2008 | - Website - |
Posted by Vitor Pereira At 05:47:39 PM On 03/18/2008 | - Website - |
(see "using this database" for details).
Posted by Florian Stamer At 10:34:53 PM On 03/20/2008 | - Website - |
I will have to negotiate with my customer though if setting checkmarks is a viable option for the users.
Posted by Jens Polster At 02:59:38 PM On 03/21/2008 | - Website - |
Here's an excerpt:
Posted by Jens Polster At 04:58:08 PM On 04/04/2008 | - Website - |