Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't update permissions on calendar folder #164

Closed
jtbennett opened this issue Mar 13, 2017 · 3 comments
Closed

Can't update permissions on calendar folder #164

jtbennett opened this issue Mar 13, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@jtbennett
Copy link

jtbennett commented Mar 13, 2017

I am trying to update permissions on a calendar folder. The recommended process is to bind to the folder after explicitly specifying that permissions be included in the PropertySet, modify the permission set, and then call FolderUpdate.

There are typically three permissions by default on every calendar: Default (none), Anonymous (none), and "any authenticated user" (read free/busy values only). When calendar permissions are retrieved, that last one is included, and its UserId value is empty -- no StandardUser, sID, or PrimarySmtpAddress. Its permissionLevel is 11, meaning custom.

That causes all updates to fail, because validation for UserId requires one of those three values. The specific error (from UserId.ts) is: "The UserId in the folder permission at index 0 is invalid. The StandardUser, PrimarySmtpAddress, or SID property must be set."

If you remove that "all authenticated users" permission before submitting, the validation error is avoided. However, the operation still fails on the server, because the <t:Updates></t:Updates> element is empty. It does not appear that changes to the Permissions property are reflected in the XML sent to the server. (This would be a bad thing to do in production in any case, since you'd be removing the ability for people to see free/busy info for their colleagues.)

Here is the code I'm using:

let ews = require('ews-javascript-api');
var exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exch.Credentials = new ews.ExchangeCredentials("foo@example.com", "foopw");
exch.Url = new ews.Uri("https://example.com/Ews/Exchange.asmx");

const calendarFolderId = new ews.FolderId(
  ews.WellKnownFolderName.Calendar,
  new ews.Mailbox("foo@example.com"))

const propertySet = new ews.PropertySet(
  ews.BasePropertySet.FirstClassProperties,
  ews.FolderSchema.Permissions)

ews.CalendarFolder.Bind(exch, calendarFolderId, propertySet)
  .then((calendarFolder) => {

    // allow user "bar" to see calendar of user "foo"
    const userId = new ews.UserId("bar@example.com")
    const permission = new ews.FolderPermission(
      userId,
      ews.FolderPermissionLevel.Reviewer
    )
    calendarFolder.Permissions.Add(permission)

    exch.UpdateFolder(calendarFolder)
      .then((response) => {
        console.log('Succeeded!')
      }, err => {
        console.log(err)
      })

  })

Any ideas on how to get around this?

Thanks!

@gautamsi
Copy link
Owner

I have to test the authenticated User scenario. other issue may be due to #124, can you make use of ews-javascript-api@next package for second part

@gautamsi gautamsi added the bug label Mar 14, 2017
@gautamsi gautamsi self-assigned this Mar 14, 2017
@gautamsi gautamsi added this to the 0.9.0 milestone Mar 14, 2017
@gautamsi
Copy link
Owner

I have to work on series of files (which has similar issues). if you want to try fix this one only, rename LoadFromXmlJsObject method to CreateFromXmlJsObjectCollection in FolderPermissionCollection.js file.

@gautamsi
Copy link
Owner

done, use ews-jsvsscript-api@next to use meanwhile.

gautamsi added a commit that referenced this issue Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants