Does anyone have som script samples for setting permissions on public folders. Preferably in VB or using WebDAV, have been looking round the Internet but haven't found anything.
Posts: 2
Joined: 31.May2005
From: US
Status: offline
I have this code working, this function can run from a client machine having outlook.
Private Sub SetFolderPermission(Server As String, AliasUser As String, FolderName As String, OwnerName As String) On Error GoTo ErrHandler 'Input : Server - Name of the Exchange Server ' AliasUser - User name used to login as ' FolderName - Name of the folder for which the permission needs to be set ' OwnerName - User Name for whom the permission needs to be set 'This function is used to set permission on a public folder ' "Public Fodlers\Projects\FolderName"
Dim Session As MAPI.Session Dim store Dim root As MAPI.Folders Dim fldr As MAPI.Folders Dim fldritm Dim acls Dim fldr_aces Dim gal Dim member Dim newace
' get a folder here Set store = Session.InfoStores.Item("Public Folders") Set root = Session.GetFolder(store.Fields(&H66310102), store.ID).Folders Set fldr = root.Item("Projects").Folders Set fldritm = fldr.Item(FolderName)
' get the aclsobject for the folder Set acls = CreateObject("MSExchange.aclobject") Set acls.cdoitem = fldritm ' set the CDO folder to CDOItem Set fldr_aces = acls.aces ' get ACEs for folder
' create a new ace and add member Set newace = CreateObject("MSExchange.ACE")
' fetch the GAL Set gal = Session.AddressLists("Global Address List") Set member = gal.AddressEntries.Item(OwnerName)
fldr_aces.Add newace ' add the ACE to the collection ' Internally the newace.id has been ' converted to the long term value. ' newace.id is now different than ' member.id above
'fldr_aces.Delete newace.ID ' then delete it ' note the use of the id property ' the ID is the long-term entry id
acls.Update ' commit changes to store CleanUp: Set store = Nothing Set root = Nothing Set fldr = Nothing Set fldritm = Nothing Set acls = Nothing Set fldr_aces = Nothing Set gal = Nothing Set member = Nothing Set newace = Nothing Set Session = Nothing Exit Sub ErrHandler: MsgBox Err.Number & " - " & Error Resume CleanUp End Sub