internal GroupMailbox GetGroupMailbox(GroupMailboxLocator group, UserMailboxLocator user, bool loadAllDetails = false) { GroupMailbox mailbox; using (IAssociationStore associationStore = this.storeProviderBuilder.Create(group, this.PerformanceTracker)) { UserAssociationAdaptor userAssociationAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, group); MailboxAssociation association = userAssociationAdaptor.GetAssociation(user); GroupMailboxBuilder groupMailboxBuilder = new GroupMailboxBuilder(group); groupMailboxBuilder.BuildFromAssociation(association); if (loadAllDetails) { ADUser aduser = group.FindAdUser(); if (aduser == null) { GroupMailboxAccessLayer.Tracer.TraceWarning <string>((long)this.GetHashCode(), "GroupMailboxAccessLayer::GetGroupMailbox. Unable to find group. LegacyDN={0}", group.LegacyDn); throw new MailboxNotFoundException(ServerStrings.ADUserNotFoundId(group.LegacyDn)); } GroupMailboxAccessLayer.Tracer.TraceDebug <string, bool, string>((long)this.GetHashCode(), "GroupMailboxAccessLayer::GetGroupMailbox. Found ADUser for group. LegacyDN={0}, IsCached={1}, OriginatingServer={2}", group.LegacyDn, aduser.IsCached, aduser.OriginatingServer); groupMailboxBuilder.BuildFromDirectory(aduser); } mailbox = groupMailboxBuilder.Mailbox; } return(mailbox); }
private ExchangeRunspaceConfiguration CreateRunspaceConfigurationFromExecutingUser() { this.CheckRecipientSessionIsNotNull(); ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = Util.ReadExchangeRunspaceConfiguration(this.recipientSession, this.ExecutingUserId); if (exchangeRunspaceConfiguration == null) { Util.Tracer.TraceError <string>((long)this.GetHashCode(), "Unable to find executing user: {0}", this.ExecutingUserId); throw new ObjectNotFoundException(ServerStrings.ADUserNotFoundId(this.ExecutingUserId)); } return(exchangeRunspaceConfiguration); }
internal static string GetUserNameFromUserId(IRecipientSession recipientSession, string userId) { Util.ThrowIfNull(recipientSession, "recipientSession"); Util.ThrowIfNullOrEmpty(userId, "userId"); ExchangeRunspaceConfiguration exchangeRunspaceConfiguration = Util.ReadExchangeRunspaceConfiguration(recipientSession, userId); if (exchangeRunspaceConfiguration == null) { Util.Tracer.TraceError <string>(0L, "Unable to find executing user: {0}", userId); throw new ObjectNotFoundException(ServerStrings.ADUserNotFoundId(userId)); } string text = (!string.IsNullOrEmpty(exchangeRunspaceConfiguration.ExecutingUserDisplayName)) ? exchangeRunspaceConfiguration.ExecutingUserDisplayName : exchangeRunspaceConfiguration.IdentityName; return(text ?? string.Empty); }
internal static ITargetMailbox CreateTargetMailbox(IRecipientSession recipientSession, MailboxDiscoverySearch searchObject, string targetLegacyDn, ITargetLocation targetLocation) { Util.ThrowIfNull(recipientSession, "recipientSession"); Util.ThrowIfNull(searchObject, "searchObject"); Util.ThrowIfNullOrEmpty(targetLegacyDn, "targetLegacyDn"); Util.ThrowIfNull(targetLocation, "targetLocation"); ADSessionSettings sessionSettings = recipientSession.SessionSettings; Util.ThrowIfNull(sessionSettings, "adSessionSettings"); ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromLegacyDN(sessionSettings, targetLegacyDn, RemotingOptions.AllowCrossSite); if (exchangePrincipal == null || string.IsNullOrEmpty(exchangePrincipal.MailboxInfo.Location.ServerFqdn)) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFoundId(targetLegacyDn)); } return(new TargetMailbox(exchangePrincipal.MailboxInfo.OrganizationId, exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), targetLegacyDn, BackEndLocator.GetBackEndWebServicesUrl(exchangePrincipal.MailboxInfo), targetLocation) { StatusMailRecipients = Util.GetStatusMailRecipients(searchObject, recipientSession) }); }
private OrganizationId ResolveOrganization(ADObjectId entryId) { OrganizationId organizationId; try { if (entryId == null) { throw new ArgumentNullException("entryId"); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(entryId), 1191, "ResolveOrganization", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\MailboxSearch\\Common\\MailboxSearchConfigurationProvider.cs"); ADRecipient adrecipient = tenantOrRootOrgRecipientSession.Read(entryId); if (adrecipient == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFoundId(entryId)); } organizationId = adrecipient.OrganizationId; } catch (InvalidOperationException arg) { Util.Tracer.TraceError <InvalidOperationException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg); throw; } catch (DataSourceOperationException arg2) { Util.Tracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg2); throw; } catch (TransientException arg3) { Util.Tracer.TraceError <TransientException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg3); throw; } catch (DataValidationException arg4) { Util.Tracer.TraceError <DataValidationException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg4); throw; } return(organizationId); }