public static FreeBusyPermissionLevel DetermineAllowedAccess(ClientContext clientContext, MailboxSession session, CalendarFolder calendarFolder, FreeBusyQuery freeBusyQuery, bool defaultFreeBusyOnly) { RawSecurityDescriptor rawSecurityDescriptor = calendarFolder.TryGetProperty(CalendarFolderSchema.FreeBusySecurityDescriptor) as RawSecurityDescriptor; if (rawSecurityDescriptor == null) { FreeBusyPermission.SecurityTracer.TraceDebug <object, CalendarFolder>(0L, "{0}: Unable to retrieve FreeBusySecurityDescriptor from folder {1}. Using None as permission level.", TraceContext.Get(), calendarFolder); return(FreeBusyPermissionLevel.None); } if (FreeBusyPermission.SecurityTracer.IsTraceEnabled(TraceType.DebugTrace)) { string sddlForm = rawSecurityDescriptor.GetSddlForm(AccessControlSections.All); FreeBusyPermission.SecurityTracer.TraceDebug <object, EmailAddress, string>(0L, "{0}: The SDDL form of calendar folder security descriptor of mailbox {1} is: {2}.", TraceContext.Get(), freeBusyQuery.Email, sddlForm); } if (defaultFreeBusyOnly) { FreeBusyPermission.SecurityTracer.TraceDebug(0L, "{0}: Using DefaultClientSecurityContext because of defaultFreeBusyOnly is set.", new object[] { TraceContext.Get() }); return(FreeBusyPermission.AccessCheck(rawSecurityDescriptor, ClientSecurityContext.FreeBusyPermissionDefaultClientSecurityContext)); } InternalClientContext internalClientContext = clientContext as InternalClientContext; if (internalClientContext != null) { return(FreeBusyPermission.FromInternalClient(internalClientContext, rawSecurityDescriptor, freeBusyQuery)); } ExternalClientContext externalClientContext = clientContext as ExternalClientContext; return(FreeBusyPermission.FromExternalClient(externalClientContext, session, rawSecurityDescriptor, freeBusyQuery)); }
public static CalendarGroupEntry Create(MailboxSession session, CalendarFolder calendarFolder, CalendarGroup parentGroup) { Util.ThrowOnNullArgument(parentGroup, "parentGroup"); Util.ThrowOnNullArgument(calendarFolder, "calendarFolder"); CalendarGroupEntry calendarGroupEntry = CalendarGroupEntry.Create(session, calendarFolder.Id.ObjectId, parentGroup.GroupClassId, parentGroup.GroupName); FolderTreeDataFlags folderTreeDataFlags = CalendarGroupEntry.ReadSharingFlags(calendarFolder); bool flag = !session.MailboxGuid.Equals(((MailboxSession)calendarFolder.Session).MailboxGuid); if (flag) { calendarGroupEntry[FolderTreeDataSchema.Type] = FolderTreeDataType.SharedFolder; calendarGroupEntry.StoreEntryId = Microsoft.Exchange.Data.Storage.StoreEntryId.ToProviderStoreEntryId(((MailboxSession)calendarFolder.Session).MailboxOwner); calendarGroupEntry.CalendarRecordKey = (byte[])calendarFolder.TryGetProperty(StoreObjectSchema.RecordKey); } else { folderTreeDataFlags |= FolderTreeDataFlags.IsDefaultStore; } calendarGroupEntry[FolderTreeDataSchema.FolderTreeDataFlags] = folderTreeDataFlags; return(calendarGroupEntry); }