Share via


WorkflowSession Item Security

WorkflowSession Item Security

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

You can control access to individual workflow items using the IWorkflowSession, ItemAuthors, and ItemReaders collections. You can populate these collections with either e-mail addresses or folder roles.

ItemAuthors

You can allow individual users, groups, or roles to modify and delete specific workflow items by using the ItemAuthors collection. Adding a user, group, or role to the collection gives exclusive Author access to the item.

The following code demonstrates how to add a user to the ItemAuthors collection.

VBScript

' In Action field:
AddAuthor "someone@example.com", 0 'MemberType=cdowfEmailAddress

' In Shared Script:
Sub AddAuthor(MbrName,MbrType)
   WorkflowSession.ItemAuthors.Add MbrName, MbrType
End Sub

The following code demonstrates how to delete a user from the ItemAuthors collection.

VBScript

' In Action field:
DeleteAuthor "someone@example.com"

' In Shared Script:
Sub DeleteAuthor(MbrName)
   WorkflowSession.ItemAuthors.Delete mbrname
End Sub

The following code demonstrates how to clear the ItemAuthors collection.

VBScript

WorkflowSession.ItemAuthors.Clear

The following code writes the list of ItemAuthors to the audit trail and enumerates the members of the ItemAuthors collection.

VBScript

' In the Action field:
WriteAuthorsToAudit

' In the Shared Script:
Sub WriteAuthorsToAudit()
   Dim str
   Dim mbr
   str = vbcrlf
   with WorkflowSession
      for each mbr in .ItemAuthors
         str = str & .ItemAuthors(mbr) & vbcrlf
      next
      .AddAuditEntry str
   end with
End Sub

ItemReaders

You can give a collection of users or roles exclusive read access to specific workflow items by using the ItemReaders property. If you are not a member of ItemReaders:

  • The item will not appear in any of your views, folders, or queries.
  • You cannot open the item even if you know the URL.

The following code demonstrates how to add a user to the ItemReaders collection.

VBScript

' In Action field:
AddReader "someone@example.com", 0 'MemberType=cdowfEmailAddress

' In Shared Script:
Sub AddReader(MbrName,MbrType)
   WorkflowSession.ItemReaders.Add MbrName, MbrType
End Sub

VBScript

The following code demonstrates how to delete a user from the ItemReaders collection.

' In Action field:
DeleteReader "someone@example.com"

' In Shared Script:
Sub DeleteReader(MbrName)
   WorkflowSession.ItemReaders.Delete mbrname
End Sub

VBScript

The following code demonstrates how to clear the ItemReaders collection.

WorkflowSession.ItemReaders.Clear

The following code writes the list of ItemReaders to the audit trail and enumerates the members of the ItemReaders collection.

VBScript

' In the Action field:
WriteReadersToAudit

' In the Shared Script:
Sub WriteReadersToAudit()
   Dim str
   Dim mbr
   str = vbcrlf
   with WorkflowSession
      for each mbr in .ItemReaders
         str = str & .ItemReaders(mbr) & vbcrlf
      next
      .AddAuditEntry str
   end with
End Sub

The following code demonstrates how to give a user's manager author and read privileges on an item.

VBScript

' Action Script Procedure:
ManagerLockOut

' Shared Script:
Sub ManagerLockOut()
   Dim str
   with WorkflowSession
      str = GetUserMgr(.Sender)
      .ItemAuthors.Add str,0 'cdowfEmailAddress
      .ItemReaders.Clear
      .ItemReaders.Add str,0 'cdowfEmailAddress
   end with
End Sub

Function GetUserMgr(UserAddress)
   with WorkflowSession
      mgrDN = .GetUserProperty(UserAddress, "manager", 0) '0 = cdowfUserEmailAddress
      GetUserMgr = .GetUserProperty(mgrDN, "mail", 1) '1 = cdowfDistinguishedName
   end with
End Function

Note that the ManagerLockOut procedure clears the ItemReaders collection before adding the manager to the ItemReaders collection. This makes the manager the only member of the collection, thus giving the manager exclusive read access to the item.

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.