protected override IConfigDataProvider CreateSession() { ADObjectId executingUserId; if (!base.TryGetExecutingUserId(out executingUserId) && this.Mailbox == null) { return(this.CreateDataProviderForNonMailboxUser()); } MailboxIdParameter mailboxIdParameter = this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError)); try { this.adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); } catch (ManagementObjectNotFoundException) { return(this.CreateDataProviderForNonMailboxUser()); } this.isBposUser = CapabilityHelper.HasBposSKUCapability(this.adUser.PersistedCapabilities); ADScopeException ex; if (!TaskHelper.UnderscopeSessionToOrganization(base.TenantGlobalCatalogSession, this.adUser.OrganizationId, true).TryVerifyIsWithinScopes(this.adUser, true, out ex)) { base.WriteError(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(this.adUser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, this.adUser.Identity); } IConfigDataProvider configDataProvider = GetApp.CreateOwaExtensionDataProvider(null, base.TenantGlobalCatalogSession, base.SessionSettings, !this.OrganizationApp, this.adUser, "New-App", false, new Task.ErrorLoggerDelegate(base.WriteError)); this.mailboxOwner = ((OWAExtensionDataProvider)configDataProvider).MailboxSession.MailboxOwner.ObjectId.ToString(); return(configDataProvider); }
protected override IConfigDataProvider CreateSession() { ADUser adUser = null; ADObjectId executingUserId; if (!base.TryGetExecutingUserId(out executingUserId)) { return(this.CreateDataProviderForNonMailboxUser()); } MailboxIdParameter mailboxIdParameter = MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError)); try { adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); } catch (ManagementObjectNotFoundException) { return(this.CreateDataProviderForNonMailboxUser()); } if (this.Identity != null && this.Identity.InternalOWAExtensionId == null) { this.Identity.InternalOWAExtensionId = OWAExtensionHelper.CreateOWAExtensionId(this, new ADObjectId(), null, this.Identity.RawExtensionName); } if (this.Organization != null) { this.SetCurrentOrganizationId(); } return(GetApp.CreateOwaExtensionDataProvider(this.Organization, base.TenantGlobalCatalogSession, base.SessionSettings, false, adUser, "Set-App", false, new Task.ErrorLoggerDelegate(base.WriteError))); }
private void GetExchangePrincipal(IRecipientSession recipientSession) { Exception ex = null; if (this.Mailbox != null) { this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, recipientSession, this.Mailbox, "Get-MobileDeviceStatistics", out ex); } else if (this.Identity != null) { TIdentity identity = this.Identity; MailboxIdParameter mailboxId = identity.GetMailboxId(); if (mailboxId == null && this.DataObject != null) { this.Identity = (TIdentity)((object)this.CreateIdentityObject()); TIdentity identity2 = this.Identity; mailboxId = identity2.GetMailboxId(); } if (mailboxId == null) { TIdentity identity3 = this.Identity; base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(identity3.ToString())), ErrorCategory.InvalidArgument, null); } this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, recipientSession, mailboxId, base.CommandRuntime.ToString(), out ex); } if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidArgument, null); } }
public static LocalizedString ImportContactListConfirmation(MailboxIdParameter identity) { return(new LocalizedString("ImportContactListConfirmation", Strings.ResourceManager, new object[] { identity })); }
protected virtual ADUser PrepareMailboxUser() { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 63, "PrepareMailboxUser", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\GetTenantXsoObjectWithFolderIdentityTaskBase.cs"); MailboxIdParameter mailboxIdParameter; if (null == this.Identity.InternalMailboxFolderId) { if (this.Identity.RawOwner != null) { mailboxIdParameter = this.Identity.RawOwner; } else { ADObjectId adObjectId; if (!base.TryGetExecutingUserId(out adObjectId)) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } mailboxIdParameter = new MailboxIdParameter(adObjectId); } } else { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalMailboxFolderId.MailboxOwnerId); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity.InternalMailboxFolderId == null) { this.Identity.InternalMailboxFolderId = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(aduser.Id, this.Identity.RawFolderStoreId, this.Identity.RawFolderPath); } return(aduser); }
private bool TryGetMailboxIdFromIdentity(string identity, out MailboxIdParameter mailboxId) { mailboxId = null; if (string.IsNullOrEmpty(identity)) { return(false); } int num = identity.IndexOf('/'); if (num <= 0) { return(false); } int num2 = identity.IndexOf("ExchangeActiveSyncDevices"); if (num2 <= 0) { return(false); } string text = identity.Substring(0, num2 - 1); if (!VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled) { text = text.Substring(text.LastIndexOf('/') + 1); } mailboxId = new MailboxIdParameter(text); return(true); }
protected override IConfigDataProvider CreateSession() { MailboxIdParameter mailboxIdParameter = null; if (this.FromMessageId != null && this.FromMessageId.RawOwner != null) { mailboxIdParameter = this.FromMessageId.RawOwner; } if (mailboxIdParameter == null) { ADObjectId executingUserId; base.TryGetExecutingUserId(out executingUserId); mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } this.adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, null, base.SessionSettings, 867, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\InboxRule\\NewInboxRule.cs"); base.VerifyIsWithinScopes(TaskHelper.UnderscopeSessionToOrganization(tenantOrRootOrgRecipientSession, this.adUser.OrganizationId, true), this.adUser, true, new DataAccessTask <InboxRule> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); XsoMailboxDataProviderBase xsoMailboxDataProviderBase; if (this.FromMessageId != null) { xsoMailboxDataProviderBase = new MailMessageDataProvider(base.SessionSettings, this.adUser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "New-InboxRule"); this.FromMessageId.InternalStoreObjectId = new MailboxStoreObjectId((ADObjectId)this.adUser.Identity, this.FromMessageId.RawStoreObjectId); } else { xsoMailboxDataProviderBase = new InboxRuleDataProvider(base.SessionSettings, this.adUser, "New-InboxRule"); } this.mailboxOwner = xsoMailboxDataProviderBase.MailboxSession.MailboxOwner.ObjectId.ToString(); return(xsoMailboxDataProviderBase); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { if (MapiTaskHelper.IsDatacenter) { base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, this.Organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId); base.RescopeToOrgId(base.CurrentOrganizationId); base.OrganizationId = base.CurrentOrganizationId; } else { base.OrganizationId = OrganizationId.ForestWideOrgId; } this.DisallowPublicFolderMoveDuringFinalization(); this.targetMailboxUser = (ADUser)base.GetDataObject <ADUser>(this.TargetMailbox, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.TargetMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.TargetMailbox.ToString())), ExchangeErrorCategory.Client); TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.CurrentOrganizationId); TenantPublicFolderConfiguration value = TenantPublicFolderConfigurationCache.Instance.GetValue(base.CurrentOrganizationId); if (value.GetLocalMailboxRecipient(this.targetMailboxUser.ExchangeGuid) == null) { base.WriteError(new RecipientTaskException(Strings.ErrorCannotMovePublicFolderIntoNonPublicFolderMailbox), ErrorCategory.InvalidArgument, this.targetMailboxUser); } string text = this.GetSourceMailboxGuid().ToString(); this.sourceMailboxUser = (ADUser)base.GetDataObject <ADUser>(MailboxIdParameter.Parse(text), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(text)), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(text)), ExchangeErrorCategory.Client); if (this.sourceMailboxUser.ExchangeGuid == this.targetMailboxUser.ExchangeGuid) { base.WriteError(new RecipientTaskException(Strings.ErrorCannotMovePublicFolderIntoSameMailbox), ErrorCategory.InvalidArgument, this.targetMailboxUser); } if (!string.IsNullOrEmpty(base.Name)) { base.ValidateName(); base.RequestName = base.Name; } else { base.RequestName = "PublicFolderMove"; } ADObjectId mdbId = null; ADObjectId mdbServerSite = null; base.Flags = (RequestFlags.IntraOrg | this.LocateAndChooseMdb(value.GetLocalMailboxRecipient(this.sourceMailboxUser.ExchangeGuid).Database, value.GetLocalMailboxRecipient(this.targetMailboxUser.ExchangeGuid).Database, this.sourceMailboxUser, this.targetMailboxUser, this.targetMailboxUser, out mdbId, out mdbServerSite)); if (base.WorkloadType == RequestWorkloadType.None) { base.WorkloadType = RequestWorkloadType.Local; } base.MdbId = mdbId; base.MdbServerSite = mdbServerSite; base.WriteVerbose(Strings.RequestQueueIdentified(base.MdbId.Name)); this.CheckRequestNameAvailability(null, null, false, MRSRequestType.PublicFolderMove, this.Organization, false); base.WriteVerbose(Strings.RequestNameAvailabilityComplete); base.InternalValidate(); } finally { TaskLogger.LogExit(); } }
protected override IConfigDataProvider CreateSession() { IRecipientSession tenantGlobalCatalogSession = base.TenantGlobalCatalogSession; MailboxIdParameter mailboxIdParameter = null; if (this.Identity != null) { if (this.Identity.InternalMessageCategoryId != null) { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalMessageCategoryId.MailboxOwnerId); } else { mailboxIdParameter = this.Identity.RawMailbox; } } if (mailboxIdParameter != null && this.Mailbox != null) { base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidArgument, this.Identity); } if (mailboxIdParameter == null) { ADObjectId executingUserId; base.TryGetExecutingUserId(out executingUserId); mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity != null && this.Identity.InternalMessageCategoryId == null) { this.Identity.InternalMessageCategoryId = new MessageCategoryId(aduser.Id, this.Identity.RawCategoryName, this.Identity.RawCategoryId); } base.VerifyIsWithinScopes(tenantGlobalCatalogSession, aduser, true, new DataAccessTask <MessageCategory> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); Exception ex = null; ExchangeErrorCategory category = (ExchangeErrorCategory)0; MessageCategoryDataProvider result = null; try { result = new MessageCategoryDataProvider(base.SessionSettings, aduser, "Get-MessageCategory"); } catch (MapiPermanentException ex2) { ex = ex2; category = ExchangeErrorCategory.ServerOperation; } catch (MapiRetryableException ex3) { ex = ex3; category = ExchangeErrorCategory.ServerTransient; } if (ex != null) { base.WriteError(new InvalidOperationException(Strings.ErrorUnableToAccessMessageCategoriesGenericMessage(ex.Message), ex), (ErrorCategory)category, aduser.Identity); } return(result); }
public static IConfigDataProvider GetDataProviderForCallAnsweringRuleTasks(UMCallAnsweringRuleIdParameter identityParam, MailboxIdParameter mailboxParam, ADSessionSettings sessionSettings, IRecipientSession globalCatalogSession, ADObjectId executingUserId, string clientString, DataAccessHelper.GetDataObjectDelegate getDataObjectDelegate, Task.TaskErrorLoggingDelegate errorLogger) { ValidateArgument.NotNull(sessionSettings, "sessionSettings"); ValidateArgument.NotNull(globalCatalogSession, "globalCatalogSession"); ValidateArgument.NotNull(getDataObjectDelegate, "getDataObjectDelegate"); ValidateArgument.NotNull(errorLogger, "errorLogger"); ValidateArgument.NotNullOrEmpty(clientString, "clientString"); MailboxIdParameter mailboxIdParameter = null; ADUser aduser = null; if (identityParam != null) { if (identityParam.CallAnsweringRuleId != null) { mailboxIdParameter = new MailboxIdParameter(identityParam.CallAnsweringRuleId.MailboxOwnerId); } else { mailboxIdParameter = identityParam.RawMailbox; } } if (mailboxIdParameter != null && mailboxParam != null) { errorLogger(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, identityParam); } if (mailboxIdParameter == null && executingUserId == null) { errorLogger(new RecipientTaskException(Strings.ErrorParameterRequired("Mailbox")), ErrorCategory.InvalidOperation, null); } if (mailboxIdParameter == null) { mailboxIdParameter = (mailboxParam ?? new MailboxIdParameter(executingUserId)); } aduser = (ADUser)getDataObjectDelegate(mailboxIdParameter, globalCatalogSession, null, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (identityParam != null && identityParam.CallAnsweringRuleId == null) { identityParam.CallAnsweringRuleId = new UMCallAnsweringRuleId(aduser.Id, (identityParam.RawRuleGuid != null) ? identityParam.RawRuleGuid.Value : Guid.Empty); } ADScopeException ex; if (!globalCatalogSession.TryVerifyIsWithinScopes(aduser, true, out ex)) { errorLogger(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(aduser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, aduser.Identity); } UMCallAnsweringRuleDataProvider result = null; try { result = new UMCallAnsweringRuleDataProvider(sessionSettings, aduser, clientString); } catch (UMRecipientValidationException) { errorLogger(new InvalidOperationException(Strings.MailboxNotUmEnabled(aduser.Identity.ToString())), ErrorCategory.InvalidOperation, aduser.Identity); } return(result); }
internal static NetworkCredential GetDefaultTestAccount(TestLiveIdAuthenticationTask.ClientAccessContext context, LiveIdAuthenticationUserTypeEnum userType) { SmtpAddress?defaultTestUser = null; if (!TestConnectivityCredentialsManager.IsExchangeMultiTenant()) { throw new InvalidOperationException(); } if (userType <= LiveIdAuthenticationUserTypeEnum.ManagedBusiness) { if (userType != LiveIdAuthenticationUserTypeEnum.ManagedConsumer) { if (userType == LiveIdAuthenticationUserTypeEnum.ManagedBusiness) { defaultTestUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(context.Instance, context.ConfigurationSession, context.Site, DatacenterUserType.BPOS); } } else { defaultTestUser = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(context.Instance, context.ConfigurationSession, context.Site, DatacenterUserType.EDU); } } else if (userType == LiveIdAuthenticationUserTypeEnum.FederatedConsumer || userType == LiveIdAuthenticationUserTypeEnum.FederatedBusiness) { throw new MailboxNotFoundException(new MailboxIdParameter(), null); } if (defaultTestUser == null) { throw new MailboxNotFoundException(new MailboxIdParameter(), null); } MailboxIdParameter localMailboxId = new MailboxIdParameter(string.Format("{0}", defaultTestUser.Value.Local)); ADUser aduser = TestLiveIdAuthenticationTask.EnsureSingleObject <ADUser>(() => localMailboxId.GetObjects <ADUser>(null, TestLiveIdAuthenticationTask.GetRecipientSession(defaultTestUser.GetValueOrDefault().Domain))); if (aduser == null) { throw new MailboxNotFoundException(new MailboxIdParameter(defaultTestUser.ToString()), null); } ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser.OrganizationId.ToADSessionSettings(), aduser); if (exchangePrincipal == null) { throw new MailboxNotFoundException(new MailboxIdParameter(defaultTestUser.ToString()), null); } NetworkCredential networkCredential = new NetworkCredential(defaultTestUser.Value.ToString(), string.Empty, context.WindowsDomain); NetworkCredential networkCredential2 = TestLiveIdAuthenticationTask.MakeCasCredential(networkCredential); LocalizedException ex = TestConnectivityCredentialsManager.LoadAutomatedTestCasConnectivityInfo(exchangePrincipal, networkCredential2); if (ex != null) { throw ex; } networkCredential.Domain = defaultTestUser.Value.Domain; networkCredential.Password = networkCredential2.Password; return(networkCredential); }
protected sealed override IConfigDataProvider CreateSession() { this.rootId = null; IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 104, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxFolder\\GetMailboxFolder.cs"); ADObjectId adobjectId; bool flag = base.TryGetExecutingUserId(out adobjectId); MailboxIdParameter mailboxIdParameter; if (this.Identity == null) { if (!flag) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } mailboxIdParameter = new MailboxIdParameter(adobjectId); if (!this.Recurse.IsPresent && !this.GetChildren.IsPresent) { this.Identity = new MailboxFolderIdParameter(adobjectId); } } else if (null == this.Identity.InternalMailboxFolderId) { if (this.Identity.RawOwner != null) { mailboxIdParameter = this.Identity.RawOwner; } else { if (!flag) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } mailboxIdParameter = new MailboxIdParameter(adobjectId); } } else { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalMailboxFolderId.MailboxOwnerId); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity != null && null == this.Identity.InternalMailboxFolderId) { this.Identity.InternalMailboxFolderId = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(aduser.Id, this.Identity.RawFolderStoreId, this.Identity.RawFolderPath); } StoreTasksHelper.CheckUserVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError)); if ((this.Recurse.IsPresent || this.GetChildren.IsPresent) && this.Identity != null) { this.rootId = this.Identity.InternalMailboxFolderId; this.Identity = null; } base.InnerMailboxFolderDataProvider = new MailboxFolderDataProvider(base.SessionSettings, aduser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "Get-MailboxFolder"); return(base.InnerMailboxFolderDataProvider); }
internal static UserWithCredential GetDefaultTestAccount(CommonTestTasks.ClientAccessContext context) { SmtpAddress?smtpAddress; if (TestConnectivityCredentialsManager.IsExchangeMultiTenant()) { smtpAddress = TestConnectivityCredentialsManager.GetMultiTenantAutomatedTaskUser(context.Instance, context.ConfigurationSession, context.Site); } else { smtpAddress = TestConnectivityCredentialsManager.GetEnterpriseAutomatedTaskUser(context.Site, context.WindowsDomain); } if (smtpAddress == null) { throw new MailboxNotFoundException(new MailboxIdParameter(), null); } MailboxIdParameter localMailboxId = new MailboxIdParameter(string.Format("{0}\\{1}", smtpAddress.Value.Domain, smtpAddress.Value.Local)); ADUser aduser = CommonTestTasks.EnsureSingleObject <ADUser>(() => localMailboxId.GetObjects <ADUser>(null, context.RecipientSession)); if (aduser == null) { throw new MailboxNotFoundException(new MailboxIdParameter(smtpAddress.ToString()), null); } ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser, null); if (exchangePrincipal == null) { throw new MailboxNotFoundException(new MailboxIdParameter(smtpAddress.ToString()), null); } NetworkCredential networkCredential = new NetworkCredential(smtpAddress.Value.ToString(), string.Empty, context.WindowsDomain); NetworkCredential networkCredential2 = CommonTestTasks.MakeCasCredential(networkCredential); bool flag = false; LocalizedException ex; if (Datacenter.IsLiveIDForExchangeLogin(true) || context.MonitoringContext) { ex = TestConnectivityCredentialsManager.LoadAutomatedTestCasConnectivityInfo(exchangePrincipal, networkCredential2); } else { ex = TestConnectivityCredentialsManager.ResetAutomatedCredentialsAndVerify(exchangePrincipal, networkCredential2, false, out flag); } if (ex != null) { throw ex; } networkCredential.Domain = smtpAddress.Value.Domain; networkCredential.Password = networkCredential2.Password; return(new UserWithCredential { User = aduser, Credential = networkCredential }); }
private ADUser GetGroupMailbox(MailboxIdParameter mailboxId, IRecipientSession recipientSession) { LocalizedString?localizedString; ADUser objectInOrganization = mailboxId.GetObjectInOrganization <ADUser>(null, recipientSession, null, out localizedString); if (objectInOrganization == null) { base.WriteError(new TaskException(localizedString.Value), (ErrorCategory)1003, null); } return(objectInOrganization); }
protected override IConfigDataProvider CreateSession() { MailboxIdParameter mailboxIdParameter = null; ADUser aduser = null; if (this.Identity != null) { if (this.Identity.InternalOWAExtensionId != null) { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalOWAExtensionId.MailboxOwnerId); } else { mailboxIdParameter = this.Identity.RawMailbox; } } if (mailboxIdParameter != null && this.Mailbox != null) { base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, this.Identity); } if (mailboxIdParameter == null) { ADObjectId adobjectId; base.TryGetExecutingUserId(out adobjectId); if (adobjectId == null && this.Mailbox == null) { return(this.CreateDataProviderForNonMailboxUser()); } mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(adobjectId, new Task.ErrorLoggerDelegate(base.WriteError))); } try { aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); } catch (ManagementObjectNotFoundException) { return(this.CreateDataProviderForNonMailboxUser()); } if (this.Identity != null && this.Identity.InternalOWAExtensionId == null) { this.Identity.InternalOWAExtensionId = OWAExtensionHelper.CreateOWAExtensionId(this, aduser.Id, null, this.Identity.RawExtensionName); } ADScopeException ex; if (!base.TenantGlobalCatalogSession.TryVerifyIsWithinScopes(aduser, true, out ex)) { base.WriteError(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(aduser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, aduser.Identity); } if (this.Organization != null) { this.SetCurrentOrganizationId(); } return(GetApp.CreateOwaExtensionDataProvider(this.Organization, base.TenantGlobalCatalogSession, base.SessionSettings, !this.OrganizationApp, aduser, "Get-App", base.IsDebugOn, new Task.ErrorLoggerDelegate(base.WriteError))); }
protected override IConfigDataProvider CreateSession() { MailboxIdParameter mailboxIdParameter = null; if (this.Identity != null) { if (this.Identity.InternalInboxRuleId != null) { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalInboxRuleId.MailboxOwnerId); } else { mailboxIdParameter = this.Identity.RawMailbox; } } if (mailboxIdParameter != null && this.Mailbox != null) { base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, this.Identity); } if (mailboxIdParameter == null) { ADObjectId executingUserId; base.TryGetExecutingUserId(out executingUserId); mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity != null && this.Identity.InternalInboxRuleId == null) { this.Identity.InternalInboxRuleId = new InboxRuleId(aduser.Id, this.Identity.RawRuleName, this.Identity.RawRuleId); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, null, base.SessionSettings, 150, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\InboxRule\\GetInboxRule.cs"); base.VerifyIsWithinScopes(TaskHelper.UnderscopeSessionToOrganization(tenantOrRootOrgRecipientSession, aduser.OrganizationId, true), aduser, true, new DataAccessTask <InboxRule> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); InboxRuleDataProvider inboxRuleDataProvider = new InboxRuleDataProvider(base.SessionSettings, aduser, "Get-InboxRule"); if (this.IncludeHidden) { inboxRuleDataProvider.IncludeHidden = true; } if (base.Fields.IsChanged("DescriptionTimeZone")) { inboxRuleDataProvider.DescriptionTimeZone = this.DescriptionTimeZone; } if (base.Fields.IsChanged("DescriptionTimeFormat")) { inboxRuleDataProvider.DescriptionTimeFormat = this.DescriptionTimeFormat; } return(inboxRuleDataProvider); }
private ADRawEntry FetchADRawEntry(MailboxIdParameter user) { OrganizationId organizationId = ((IConfigurationSession)base.DataSession).GetOrgContainer().OrganizationId; IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 105, "FetchADRawEntry", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\ClientAccessRules\\TestClientAccessRule.cs"); tenantOrRootOrgRecipientSession.UseGlobalCatalog = true; List <ADUser> list = new List <ADUser>(base.GetDataObjects <ADUser>(user, tenantOrRootOrgRecipientSession, null)); if (list.Count != 1) { base.WriteError(new RecipientTaskException(RulesTasksStrings.TestClientAccessRuleUserNotFoundOrMoreThanOne(user.ToString())), ErrorCategory.InvalidArgument, null); } return(list[0]); }
private static LocalizedString FormatContactForVerboseOutput(MailboxIdParameter mailbox, Item contactItem) { contactItem.Load(new PropertyDefinition[] { ItemSchema.Id, ContactSchema.PersonId, StoreObjectSchema.DisplayName }); return(new LocalizedString(string.Format(CultureInfo.InvariantCulture, "Updated contact in Mailbox: {0}. EntryID: {1}, PersonId: {2}, DisplayNameFirstLast: '{3}'.", new object[] { mailbox, contactItem.Id.ObjectId, contactItem.GetValueOrDefault <PersonId>(ContactSchema.PersonId), contactItem.GetValueOrDefault <string>(ContactBaseSchema.DisplayNameFirstLast) }))); }
private UMPlayOnPhoneDataProvider CreateProviderObjectForPlayOnPhone() { MailboxIdParameter mailboxIdParameter = this.CallAnsweringRuleId.RawMailbox; if (mailboxIdParameter == null) { ADObjectId adObjectId; if (!base.TryGetExecutingUserId(out adObjectId)) { base.WriteError(new MailboxMustBeSpecifiedException("CallAnsweringRuleId"), ErrorCategory.InvalidArgument, null); } mailboxIdParameter = new MailboxIdParameter(adObjectId); } this.ResolveADUser(mailboxIdParameter); return(new UMPlayOnPhoneDataProvider(this.adUser, new Guid?(this.CallAnsweringRuleId.RawRuleGuid.Value))); }
protected override IConfigDataProvider CreateSession() { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 63, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\MailboxFolder\\NewMailboxFolder.cs"); ADObjectId adobjectId; bool flag = base.TryGetExecutingUserId(out adobjectId); MailboxIdParameter mailboxIdParameter; if (this.Parent == null) { if (!flag) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } mailboxIdParameter = new MailboxIdParameter(adobjectId); this.Parent = new MailboxFolderIdParameter(adobjectId); } else if (null == this.Parent.InternalMailboxFolderId) { if (this.Parent.RawOwner != null) { mailboxIdParameter = this.Parent.RawOwner; } else { if (!flag) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } mailboxIdParameter = new MailboxIdParameter(adobjectId); } } else { mailboxIdParameter = new MailboxIdParameter(this.Parent.InternalMailboxFolderId.MailboxOwnerId); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); base.VerifyIsWithinScopes(tenantOrRootOrgRecipientSession, aduser, true, new DataAccessTask <MailboxFolder> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); StoreTasksHelper.CheckUserVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError)); if (this.Parent != null && null == this.Parent.InternalMailboxFolderId) { this.Parent.InternalMailboxFolderId = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(aduser.Id, this.Parent.RawFolderStoreId, this.Parent.RawFolderPath); } this.innerMailboxFolderDataProvider = new MailboxFolderDataProvider(base.SessionSettings, aduser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "New-MailboxFolder"); return(this.innerMailboxFolderDataProvider); }
protected override IConfigDataProvider CreateSession() { MailboxIdParameter mailboxIdParameter = null; if (this.Identity != null) { if (this.Identity.InternalOWAExtensionId != null) { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalOWAExtensionId.MailboxOwnerId); } else { mailboxIdParameter = this.Identity.RawMailbox; } } if (mailboxIdParameter != null && this.Mailbox != null) { base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, this.Identity); } if (mailboxIdParameter == null) { ADObjectId executingUserId; if (!base.TryGetExecutingUserId(out executingUserId) && this.Mailbox == null) { base.WriteError(new LocalizedException(Strings.ErrorParameterRequired("Mailbox")), ErrorCategory.InvalidArgument, null); } mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } this.adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity != null && this.Identity.InternalOWAExtensionId == null) { this.Identity.InternalOWAExtensionId = OWAExtensionHelper.CreateOWAExtensionId(this, this.adUser.Id, null, this.Identity.RawExtensionName); } ADScopeException ex; if (!base.TenantGlobalCatalogSession.TryVerifyIsWithinScopes(this.adUser, true, out ex)) { base.WriteError(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(this.adUser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, this.adUser.Identity); } OWAExtensionDataProvider owaextensionDataProvider = GetApp.CreateOwaExtensionDataProvider(null, base.TenantGlobalCatalogSession, base.SessionSettings, true, this.adUser, "EnableDisable-App", false, new Task.ErrorLoggerDelegate(base.WriteError)); this.mailboxOwner = owaextensionDataProvider.MailboxSession.MailboxOwner.ObjectId.ToString(); return(owaextensionDataProvider); }
protected virtual MailboxIdParameter GetMailboxIdParameter() { MailboxIdParameter result; if (this.Identity != null && this.Identity.MailboxIdParameter != null) { result = this.Identity.MailboxIdParameter; } else { ADObjectId adObjectId; if (!base.TryGetExecutingUserId(out adObjectId)) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } result = new MailboxIdParameter(adObjectId); } return(result); }
internal static ADUser ResolvePartitionMailbox(MailboxIdParameter partitionMailboxIdentity, IRecipientSession tenantGlobalCatalogSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.ErrorLoggerDelegate writeError, bool datacenterFirstOrg) { ADUser aduser; if (partitionMailboxIdentity != null) { ADObjectId rootID = null; if (datacenterFirstOrg) { rootID = ADSystemConfigurationSession.GetFirstOrgUsersContainerId(); } aduser = (ADUser)getDataObject(partitionMailboxIdentity, tenantGlobalCatalogSession, rootID, null, new LocalizedString?(Strings.MigrationPartitionMailboxNotFound), new LocalizedString?(Strings.MigrationPartitionMailboxAmbiguous), ExchangeErrorCategory.Client); if (!aduser.PersistedCapabilities.Contains(Capability.OrganizationCapabilityMigration)) { writeError(new MigrationPartitionMailboxInvalidException(aduser.Alias), ExchangeErrorCategory.Client, partitionMailboxIdentity); } } else { List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(tenantGlobalCatalogSession, OrganizationCapability.Migration); if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0) { organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(tenantGlobalCatalogSession, OrganizationCapability.Management); } if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0) { writeError(new MigrationPartitionMailboxNotFoundException(), ExchangeErrorCategory.Client, null); } else if (organizationMailboxesByCapability.Count > 1) { writeError(new MigrationPartitionMailboxAmbiguousException(), ExchangeErrorCategory.Client, null); } aduser = organizationMailboxesByCapability[0]; } if (aduser.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox || aduser.Database == null) { writeError(new MigrationPartitionMailboxInvalidException(aduser.Alias), ExchangeErrorCategory.Client, partitionMailboxIdentity); } return(aduser); }
internal static MailboxData DiscoverPublicFolderTestMailbox(IIdentityParameter identity, IConfigurationSession configurationSession, IRecipientSession recipientSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.ErrorLoggerDelegate writeError) { if (identity == null) { Organization orgContainer = configurationSession.GetOrgContainer(); if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid != default(Guid)) { identity = new MailboxIdParameter(orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid.ToString()); } else { writeError(new MigrationPermanentException(Strings.ErrorUnableToFindValidPublicFolderMailbox), ExchangeErrorCategory.Client, null); } } ADUser aduser = RequestTaskHelper.ResolveADUser(recipientSession, recipientSession, serverSettings, identity, new OptionalIdentityData(), null, getDataObject, writeVerbose, writeError, true); if (aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox) { writeError(new MigrationPermanentException(Strings.ErrorNotPublicFolderMailbox(identity.RawIdentity)), ExchangeErrorCategory.Client, null); } return(MailboxData.CreateFromADUser(aduser)); }
protected override IConfigDataProvider CreateSession() { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 82, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Mobility\\Aggregation\\RemoveSubscriptionBase.cs"); MailboxIdParameter mailboxIdParameter = this.GetMailboxIdParameter(); ADUser adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorUserNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorUserNotUnique(mailboxIdParameter.ToString()))); IRecipientSession session = AggregationTaskUtils.VerifyIsWithinWriteScopes(tenantOrRootOrgRecipientSession, adUser, new Task.TaskErrorLoggingDelegate(this.WriteDebugInfoAndError)); AggregationSubscriptionDataProvider result = null; try { AggregationType aggregationType = this.AggregationType; if (this.Identity != null && this.Identity.AggregationType != null) { aggregationType = this.Identity.AggregationType.Value; } result = SubscriptionConfigDataProviderFactory.Instance.CreateSubscriptionDataProvider(aggregationType, AggregationTaskType.Remove, session, adUser); } catch (MailboxFailureException exception) { this.WriteDebugInfoAndError(exception, ErrorCategory.InvalidArgument, mailboxIdParameter); } return(result); }
internal static ADUser FetchRecipientFromMailboxId(string domainController, MailboxIdParameter mailbox, out IRecipientSession session, OrganizationId orgId) { session = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(domainController, true, ConsistencyMode.IgnoreInvalid, orgId.ToADSessionSettings(), 191, "FetchRecipientFromMailboxId", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Elc\\StoreRetentionPolicyTagHelper.cs"); LocalizedString? localizedString = null; IEnumerable<ADUser> objects = mailbox.GetObjects<ADUser>(null, session, null, out localizedString); ADUser aduser = null; if (objects != null) { foreach (ADUser aduser2 in objects) { if (aduser != null) { throw new ManagementObjectAmbiguousException(Strings.ErrorRecipientNotUnique(mailbox.ToString())); } aduser = aduser2; } } if (aduser == null) { throw new ManagementObjectNotFoundException(localizedString ?? Strings.ErrorObjectNotFound(mailbox.ToString())); } return aduser; }
protected override void InternalValidate() { MailboxIdParameter mailboxIdParameter = null; try { base.InternalValidate(); } catch (ManagementObjectNotFoundException) { if (this.Identity == null || !this.TryGetMailboxIdFromIdentity(this.Identity.ToString(), out mailboxIdParameter)) { throw; } this.deviceExistsinAD = false; } if (base.HasErrors) { return; } if (MobileDeviceTaskHelper.IsRunningUnderMyOptionsRole(this, base.TenantGlobalCatalogSession, base.SessionSettings)) { ADObjectId adobjectId; if (!base.TryGetExecutingUserId(out adobjectId)) { throw new ExecutingUserPropertyNotFoundException("executingUserid"); } if (!base.DataObject.Id.Parent.Parent.Equals(adobjectId) || (mailboxIdParameter != null && !mailboxIdParameter.Equals(adobjectId))) { base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null); } } Exception ex = null; if (mailboxIdParameter == null) { mailboxIdParameter = this.Identity.GetMailboxId(); } if (mailboxIdParameter == null && base.DataObject != null) { this.Identity = new MobileDeviceIdParameter(base.DataObject); mailboxIdParameter = this.Identity.GetMailboxId(); } if (mailboxIdParameter == null) { base.WriteError(new LocalizedException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null); } this.principal = MobileDeviceTaskHelper.GetExchangePrincipal(base.SessionSettings, this.CreateTenantGlobalCatalogSession(base.SessionSettings), mailboxIdParameter, "Remove-MobileDevice", out ex); if (ex != null) { base.WriteError(ex, ErrorCategory.InvalidArgument, null); } if (DeviceInfo.IsThrottlingLimitsExceeded((IConfigurationSession)base.DataSession, this.principal, out this.activeSyncDevices)) { uint maxDeviceDeleteCount = 0U; using (IBudget budget = StandardBudget.Acquire(this.principal.Sid, BudgetType.Eas, this.principal.MailboxInfo.OrganizationId.ToADSessionSettings())) { IThrottlingPolicy throttlingPolicy = budget.ThrottlingPolicy; maxDeviceDeleteCount = throttlingPolicy.EasMaxDeviceDeletesPerMonth.Value; } base.WriteError(new LocalizedException(Strings.MaxDeviceDeletesPerMonthReached(this.activeSyncDevices.ObjectsDeletedThisPeriod, maxDeviceDeleteCount)), ErrorCategory.WriteError, null); } }
private void ValidateCSV() { Stream stream = null; try { Stream stream2; if (this.CSVStream != null) { stream2 = this.CSVStream; } else { stream2 = new MemoryStream(this.CSVData); stream = stream2; } PublicFolderMigrationRequestCsvSchema publicFolderMigrationRequestCsvSchema = new PublicFolderMigrationRequestCsvSchema(); publicFolderMigrationRequestCsvSchema.PropertyValidationError += delegate(CsvRow row, string columnName, PropertyValidationError error) { base.WriteError(new RecipientTaskException(Strings.ErrorParsingCSV(row.Index, columnName, error.Description)), ExchangeErrorCategory.Client, null); }; Dictionary <string, Guid> dictionary = new Dictionary <string, Guid>(); Dictionary <string, Guid> dictionary2 = null; bool flag = false; foreach (CsvRow csvRow in publicFolderMigrationRequestCsvSchema.Read(stream2)) { if (csvRow.Index != 0) { if (!flag) { dictionary2 = this.CreateMailboxNameToGuidMap(); flag = true; } string text = csvRow["FolderPath"]; string identity = csvRow["TargetMailbox"]; MailboxIdParameter mailboxIdParameter = MailboxIdParameter.Parse(identity); ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, this.recipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (dictionary.ContainsKey(text)) { base.WriteError(new RecipientTaskException(Strings.ErrorParsingCSV(csvRow.Index, "FolderPath", "DuplicateFolderPathEntry")), ExchangeErrorCategory.Client, null); } else if (!dictionary2.ContainsValue(aduser.ExchangeGuid)) { base.WriteError(new RecipientTaskException(Strings.ErrorParsingCSV(csvRow.Index, "TargetMailbox", "InvalidPublicFolderMailbox")), ExchangeErrorCategory.Client, null); } dictionary.Add(text, aduser.ExchangeGuid); this.folderToMailboxMapping.Add(new FolderToMailboxMapping(text, aduser.ExchangeGuid)); } } if (!flag) { base.WriteError(new RecipientTaskException(Strings.ErrorParsingCSV(1, "FolderPath", "NoInputDataFound")), ExchangeErrorCategory.Client, null); } } finally { if (stream != null) { stream.Dispose(); stream = null; } } }
internal static ExchangePrincipal GetExchangePrincipal(ADSessionSettings sessionSettings, IRecipientSession recipientSession, MailboxIdParameter mailbox, string cmdletName, out Exception localizedError, out ADUser adUser) { localizedError = null; adUser = null; mailbox.SearchWithDisplayName = false; IEnumerable <ADRecipient> objects = mailbox.GetObjects <ADRecipient>(null, recipientSession); ExchangePrincipal result; using (IEnumerator <ADRecipient> enumerator = objects.GetEnumerator()) { if (!enumerator.MoveNext()) { localizedError = new RecipientNotFoundException(mailbox.ToString()); result = null; } else { ADUser aduser = enumerator.Current as ADUser; if (enumerator.MoveNext()) { localizedError = new RecipientNotUniqueException(mailbox.ToString()); result = null; } else if (aduser == null || (aduser.RecipientType != RecipientType.UserMailbox && aduser.RecipientType != RecipientType.MailUser)) { localizedError = new RecipientNotValidException(mailbox.ToString()); result = null; } else if ((int)aduser.ExchangeVersion.ExchangeBuild.Major > Server.CurrentExchangeMajorVersion || (int)aduser.ExchangeVersion.ExchangeBuild.Major < Server.Exchange2009MajorVersion) { localizedError = new ServerVersionNotSupportedException(cmdletName, Server.CurrentExchangeMajorVersion, (int)aduser.ExchangeVersion.ExchangeBuild.Major); result = null; } else { ADSessionSettings adSettings = sessionSettings; IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.FullyConsistent, sessionSettings, 125, "GetExchangePrincipal", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\AirSync\\MobileDeviceTaskHelper.cs"); if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(tenantOrRootOrgRecipientSession, aduser)) { IDirectorySession directorySession = TaskHelper.UnderscopeSessionToOrganization(tenantOrRootOrgRecipientSession, aduser.OrganizationId, sessionSettings, true); adSettings = directorySession.SessionSettings; } ExchangePrincipal exchangePrincipal = null; try { adUser = aduser; exchangePrincipal = ExchangePrincipal.FromADUser(adSettings, aduser, RemotingOptions.AllowCrossSite); } catch (UserHasNoMailboxException ex) { localizedError = ex; return(null); } if (exchangePrincipal == null) { localizedError = new ExchangePrincipalNotFoundException(aduser.ToString()); result = null; } else { result = exchangePrincipal; } } } } return(result); }
internal static ExchangePrincipal GetExchangePrincipal(ADSessionSettings sessionSettings, IRecipientSession recipientSession, MailboxIdParameter mailbox, string cmdletName, out Exception localizedError) { ADUser aduser = null; return(MobileDeviceTaskHelper.GetExchangePrincipal(sessionSettings, recipientSession, mailbox, cmdletName, out localizedError, out aduser)); }