private void UpdateHold(Guid id, bool add) { try { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, this.RecipientSession.SessionSettings, 418, "UpdateHold", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Compliance\\ExMailboxComplianceItemContainer.cs"); ADRecipient adUser = ExMailboxComplianceItemContainer.GetAdUser(tenantOrRootOrgRecipientSession, this.ExternalDirectoryObjectId, add); string holdId = ExMailboxComplianceItemContainer.GetHoldId(id); if (add) { MailboxDiscoverySearch.AddInPlaceHold(adUser, holdId, tenantOrRootOrgRecipientSession); } else { MailboxDiscoverySearch.RemoveInPlaceHold(adUser, holdId, tenantOrRootOrgRecipientSession); } } catch (ComplianceTaskPermanentException) { throw; } catch (Exception ex) { ExTraceGlobals.StorageTracer.TraceError <string, Exception, string>(0L, "Failed to {2} hold on mailbox '{0}'. Exception: {1}", this.ExternalDirectoryObjectId, ex, add ? "place" : "remove"); throw new ComplianceTaskPermanentException(string.Format("Failed to {0} hold on mailbox '{1}'", add ? "place" : "remove", this.ExternalDirectoryObjectId), ex, UnifiedPolicyErrorCode.Unknown); } }
public override bool HasPolicy(Guid id, PolicyScenario scenario) { if (scenario == PolicyScenario.Hold) { try { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, this.RecipientSession.SessionSettings, 327, "HasPolicy", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Compliance\\ExMailboxComplianceItemContainer.cs"); ADRecipient adUser = ExMailboxComplianceItemContainer.GetAdUser(tenantOrRootOrgRecipientSession, this.ExternalDirectoryObjectId, true); string holdId = ExMailboxComplianceItemContainer.GetHoldId(id); return(adUser.InPlaceHolds.Contains(holdId)); } catch (Exception arg) { ExTraceGlobals.StorageTracer.TraceError <string, Exception>(0L, "Failed to find out if mailbox '{0}' has hold. Exception: {1}", this.ExternalDirectoryObjectId, arg); throw; } } throw new NotImplementedException("Scenario is not supported: " + scenario.ToString()); }