protected virtual IConfigDataProvider CreateMailboxDataProvider(ADUser adUser)
 {
     return(new MailboxStoreTypeProvider(adUser)
     {
         MailboxSession = StoreTasksHelper.OpenMailboxSession(ExchangePrincipal.FromADUser(base.SessionSettings, adUser, RemotingOptions.AllowCrossSite), "GetMailboxConfigurationTaskBase")
     });
 }
        protected sealed override IConfigDataProvider CreateSession()
        {
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 51, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\SetMailboxConfigurationTaskBase.cs");
            ADUser            aduser = (ADUser)base.GetDataObject <ADUser>(this.Identity, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.Identity.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.Identity.ToString())));

            StoreTasksHelper.CheckUserVersion(aduser, new Task.TaskErrorLoggingDelegate(base.WriteError));
            IDirectorySession directorySession = tenantOrRootOrgRecipientSession;

            if (this.ReadUserFromDC)
            {
                IRecipientSession tenantOrRootOrgRecipientSession2 = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, base.SessionSettings, 70, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\StoreTasks\\UserOptions\\SetMailboxConfigurationTaskBase.cs");
                tenantOrRootOrgRecipientSession2.UseGlobalCatalog = false;
                if (aduser.OrganizationId.Equals(OrganizationId.ForestWideOrgId))
                {
                    tenantOrRootOrgRecipientSession2.EnforceDefaultScope = false;
                }
                ADUser aduser2 = (ADUser)tenantOrRootOrgRecipientSession2.Read <ADUser>(aduser.Identity);
                if (aduser2 != null)
                {
                    aduser           = aduser2;
                    directorySession = tenantOrRootOrgRecipientSession2;
                }
            }
            if (TaskHelper.ShouldUnderscopeDataSessionToOrganization(directorySession, aduser))
            {
                directorySession = TaskHelper.UnderscopeSessionToOrganization(directorySession, aduser.OrganizationId, true);
            }
            base.VerifyIsWithinScopes(directorySession, aduser, true, new DataAccessTask <TDataObject> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope));
            this.mailboxStoreIdParameter = new MailboxStoreIdParameter(new MailboxStoreIdentity(aduser.Id));
            return(this.CreateMailboxDataProvider(aduser));
        }
        private IEnumerable <CalendarLogAnalysis> LoadMailboxLogs(IEnumerable <CalendarLog> logs)
        {
            if (this.principal == null)
            {
                throw new InvalidOperationException("The Analyzer was not provided with session objects during construction and cannot connect to the specified mailbox");
            }
            List <CalendarLogAnalysis> list = new List <CalendarLogAnalysis>();

            using (MailboxSession mailboxSession = StoreTasksHelper.OpenMailboxSession(this.principal, "Get-CalendarDiagnosticLogs"))
            {
                foreach (CalendarLog calendarLog in logs)
                {
                    CalendarLogId calendarLogId = calendarLog.Identity as CalendarLogId;
                    if (calendarLogId != null)
                    {
                        UriHandler uriHandler = new UriHandler(calendarLogId.Uri);
                        if (uriHandler.IsValidLink && !uriHandler.IsFileLink)
                        {
                            CalendarLogAnalysis calendarLogAnalysis = this.LoadFromMailbox(calendarLogId, uriHandler, mailboxSession);
                            if (calendarLogAnalysis != null)
                            {
                                list.Add(calendarLogAnalysis);
                            }
                        }
                    }
                }
            }
            return(list);
        }
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         StoreTasksHelper.CleanupMailboxStoreTypeProvider(base.DataSession);
     }
 }
        protected override IConfigDataProvider CreateMailboxDataProvider(ADUser adUser)
        {
            MailboxStoreTypeProvider mailboxStoreTypeProvider = new MailboxStoreTypeProvider(adUser);
            ExchangePrincipal        principal = ExchangePrincipal.FromADUser(base.SessionSettings, adUser, RemotingOptions.AllowCrossSite);

            mailboxStoreTypeProvider.MailboxSession = StoreTasksHelper.OpenMailboxSession(principal, "Set-MailboxConfiguration", this.LocalizeDefaultFolderName.IsPresent);
            return(mailboxStoreTypeProvider);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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 void InternalStateReset()
 {
     StoreTasksHelper.CleanupMailboxStoreTypeProvider(base.DataSession);
     base.InternalStateReset();
 }
Ejemplo n.º 9
0
        private void OutputLogs()
        {
            TaskLogger.LogEnter();
            ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(base.SessionSettings, this.logSourceUser, RemotingOptions.AllowCrossSite);

            using (MailboxSession mailboxSession = StoreTasksHelper.OpenMailboxSession(exchangePrincipal, "Get-CalendarDiagnosticLogs"))
            {
                Dictionary <string, List <VersionedId> > allCalendarLogItems = this.GetAllCalendarLogItems(mailboxSession);
                if (allCalendarLogItems.Keys.Count == 0)
                {
                    this.WriteWarning(Strings.CalendarDiagnosticLogsNotFound(this.Subject, mailboxSession.MailboxOwner.MailboxInfo.DisplayName));
                    return;
                }
                MailboxSession mailboxSession2 = null;
                try
                {
                    if (this.outputMailboxUser != null)
                    {
                        ExchangePrincipal principal = exchangePrincipal;
                        mailboxSession2 = StoreTasksHelper.OpenMailboxSession(principal, "Get-CalendarDiagnosticLogs");
                    }
                    else
                    {
                        mailboxSession2 = mailboxSession;
                    }
                    SmtpAddress address = new SmtpAddress(exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString());
                    foreach (KeyValuePair <string, List <VersionedId> > keyValuePair in allCalendarLogItems)
                    {
                        if (!string.IsNullOrEmpty(this.LogLocation))
                        {
                            this.diagnosticLogWriter = new CalendarDiagnosticLogFileWriter(this.LogLocation, mailboxSession.MailboxOwner.MailboxInfo.DisplayName, address.Domain);
                        }
                        base.WriteProgress(Strings.GetCalendarDiagnosticLog(this.Identity.ToString()), Strings.SavingCalendarLogs, 0);
                        List <VersionedId> value = keyValuePair.Value;
                        int count = value.Count;
                        foreach (VersionedId storeId in value)
                        {
                            using (Item item = Item.Bind(mailboxSession, storeId))
                            {
                                if (!(item.LastModifiedTime > this.EndDate) && !(item.LastModifiedTime < this.StartDate))
                                {
                                    if (!string.IsNullOrEmpty(this.LogLocation))
                                    {
                                        string text = null;
                                        if (Directory.Exists(this.LogLocation))
                                        {
                                            FileInfo fileInfo = this.diagnosticLogWriter.LogItem(item, out text);
                                            if (fileInfo == null && !string.IsNullOrEmpty(text))
                                            {
                                                base.WriteWarning(text);
                                            }
                                            else
                                            {
                                                base.WriteResult(new CalendarLog(item, fileInfo, (string)address));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        base.WriteResult(new CalendarLog(item, (string)address));
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (mailboxSession2 != null)
                    {
                        mailboxSession2.Dispose();
                    }
                }
            }
            TaskLogger.LogExit();
        }
Ejemplo n.º 10
0
 internal static MailboxSession OpenMailboxSession(ExchangePrincipal principal, string taskName)
 {
     return(StoreTasksHelper.OpenMailboxSession(principal, taskName, false));
 }