Exemplo n.º 1
0
 protected override void ResolveCurrentOrgIdBasedOnIdentity(IIdentityParameter identity)
 {
     try
     {
         base.ResolveCurrentOrgIdBasedOnIdentity(identity);
     }
     catch (ManagementObjectNotFoundException)
     {
     }
 }
        protected override void ResolveCurrentOrgIdBasedOnIdentity(IIdentityParameter identity)
        {
            ADSessionSettings     sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, ConfigScopes.TenantSubTree, 107, "ResolveCurrentOrgIdBasedOnIdentity", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Relocation\\NewTenantRelocationRequest.cs");

            tenantOrTopologyConfigurationSession.UseConfigNC = false;
            ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.Identity, tenantOrTopologyConfigurationSession, null, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.Identity.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.Identity.ToString())));

            base.SetCurrentOrganizationWithScopeSet(adorganizationalUnit.OrganizationId);
        }
        protected override void ResolveCurrentOrgIdBasedOnIdentity(IIdentityParameter identity)
        {
            MailboxFolderIdParameter identity2 = this.Identity;

            if (identity2 != null && identity2.RawOwner != null && base.CurrentOrganizationId != null && base.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId))
            {
                OrganizationId organizationId = identity2.RawOwner.ResolveOrganizationIdBasedOnIdentity(base.ExecutingUserOrganizationId);
                if (organizationId != null && !organizationId.Equals(base.CurrentOrganizationId))
                {
                    base.SetCurrentOrganizationWithScopeSet(organizationId);
                }
            }
        }
Exemplo n.º 4
0
        internal static MailboxData DiscoverTestMailbox(IIdentityParameter identity, IRecipientSession adSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.ErrorLoggerDelegate writeError)
        {
            if (identity == null)
            {
                MigrationADProvider migrationADProvider = new MigrationADProvider(adSession);
                return(migrationADProvider.GetMailboxDataForManagementMailbox());
            }
            ADUser      aduser      = RequestTaskHelper.ResolveADUser(adSession, adSession, serverSettings, identity, null, null, getDataObject, writeVerbose, writeError, true);
            MailboxData mailboxData = new MailboxData(aduser.ExchangeGuid, new Fqdn(aduser.ServerName), aduser.LegacyExchangeDN, aduser.Id, aduser.ExchangeObjectId);

            mailboxData.Update(identity.RawIdentity, aduser.OrganizationId);
            return(mailboxData);
        }
Exemplo n.º 5
0
 protected virtual void ResolveCurrentOrgIdBasedOnIdentity(IIdentityParameter identity)
 {
     if (this.ShouldSupportPreResolveOrgIdBasedOnIdentity() && base.CurrentOrganizationId != null && base.CurrentOrganizationId.Equals(OrganizationId.ForestWideOrgId))
     {
         ADIdParameter adidParameter = identity as ADIdParameter;
         if (adidParameter != null)
         {
             OrganizationId organizationId = adidParameter.ResolveOrganizationIdBasedOnIdentity(base.ExecutingUserOrganizationId);
             if (organizationId != null && !organizationId.Equals(base.CurrentOrganizationId))
             {
                 this.SetCurrentOrganizationWithScopeSet(organizationId);
             }
         }
     }
 }
Exemplo n.º 6
0
        protected IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, OptionalIdentityData optionalData, LocalizedString?notFoundError, LocalizedString?multipleFoundError, ExchangeErrorCategory errorCategory) where TObject : IConfigurable, new()
        {
            IConfigurable         result = null;
            LocalizedString?      localizedString;
            IEnumerable <TObject> dataObjects = this.GetDataObjects <TObject>(id, session, rootID, optionalData, out localizedString);
            Exception             ex          = null;

            using (IEnumerator <TObject> enumerator = dataObjects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    result = enumerator.Current;
                    if (enumerator.MoveNext())
                    {
                        ex = new ManagementObjectAmbiguousException(multipleFoundError ?? Strings.ErrorManagementObjectAmbiguous(id.ToString()));
                    }
                }
                else if (notFoundError != null)
                {
                    LocalizedString message;
                    if (localizedString != null)
                    {
                        LocalizedString?localizedString2 = notFoundError;
                        string          notFound         = (localizedString2 != null) ? localizedString2.GetValueOrDefault() : null;
                        LocalizedString?localizedString3 = localizedString;
                        message = Strings.ErrorNotFoundWithReason(notFound, (localizedString3 != null) ? localizedString3.GetValueOrDefault() : null);
                    }
                    else
                    {
                        message = notFoundError.Value;
                    }
                    ex = new ManagementObjectNotFoundException(message);
                }
                else
                {
                    ex = new ManagementObjectNotFoundException(localizedString ?? this.GetErrorMessageObjectNotFound(id.ToString(), typeof(TObject).ToString(), (this.DataSession != null) ? this.DataSession.Source : null));
                }
            }
            if (ex != null)
            {
                if (errorCategory != (ExchangeErrorCategory)0)
                {
                    RecipientTaskHelper.SetExceptionErrorCategory(ex, errorCategory);
                }
                throw ex;
            }
            return(result);
        }
Exemplo n.º 7
0
        internal static T FindById <T>(IIdentityParameter idParameter, IConfigDataProvider dataProvider) where T : IConfigurable, new()
        {
            IEnumerable <T> objects = idParameter.GetObjects <T>(null, dataProvider);
            T result;

            using (IEnumerator <T> enumerator = objects.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    throw new ManagementObjectNotFoundException(Strings.ErrorManagementObjectNotFound(idParameter.ToString()));
                }
                result = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    throw new ManagementObjectAmbiguousException(Strings.ErrorManagementObjectAmbiguous(idParameter.ToString()));
                }
            }
            return(result);
        }
Exemplo n.º 8
0
 public static void CheckServerObjectForCopyTask(IIdentityParameter serverIdParam, Task.TaskErrorLoggingDelegate writeError, Server server)
 {
     if (server == null)
     {
         throw new ArgumentNullException("server");
     }
     if (writeError == null)
     {
         throw new ArgumentNullException("writeError");
     }
     if (!server.IsMailboxServer)
     {
         writeError(server.GetServerRoleError(ServerRole.Mailbox), ErrorCategory.InvalidOperation, serverIdParam);
     }
     if (!server.IsE14OrLater)
     {
         writeError(new InvalidOperationException(Strings.ErrorServerNotE14OrLater(server.Name)), ErrorCategory.InvalidOperation, serverIdParam);
     }
 }
        private IRequestIndexEntry GetEntry()
        {
            LocalizedString?notFoundError      = new LocalizedString?(Strings.ErrorNotEnoughInformationToFindRequest);
            LocalizedString?multipleFoundError = new LocalizedString?(Strings.ErrorNotEnoughInformationToFindUniqueRequest);
            TIdentity       identity           = this.Identity;

            if (identity.IndexToUse == null)
            {
                base.WriteError(new UnknownRequestIndexPermanentException(null), ErrorCategory.InvalidArgument, this.Identity);
                return(null);
            }
            TIdentity identity2 = this.Identity;

            if (identity2.IndexToUse.RequestIndexEntryType == null)
            {
                return(null);
            }
            TIdentity identity3 = this.Identity;

            if (identity3.IndexToUse.RequestIndexEntryType == typeof(MRSRequestWrapper))
            {
                IIdentityParameter    id                   = this.Identity;
                IConfigDataProvider   indexProvider        = this.rjProvider.IndexProvider;
                IConfigurationSession configurationSession = this.currentOrgConfigSession;
                TIdentity             identity4            = this.Identity;
                return((IRequestIndexEntry)base.GetDataObject <MRSRequestWrapper>(id, indexProvider, ADHandler.GetRootId(configurationSession, identity4.RequestType), notFoundError, multipleFoundError));
            }
            TIdentity identity5 = this.Identity;

            if (identity5.IndexToUse.RequestIndexEntryType == typeof(MRSRequestMailboxEntry))
            {
                IIdentityParameter    id2                   = this.Identity;
                IConfigDataProvider   indexProvider2        = this.rjProvider.IndexProvider;
                IConfigurationSession configurationSession2 = this.currentOrgConfigSession;
                TIdentity             identity6             = this.Identity;
                return((IRequestIndexEntry)base.GetDataObject <MRSRequestMailboxEntry>(id2, indexProvider2, ADHandler.GetRootId(configurationSession2, identity6.RequestType), notFoundError, multipleFoundError));
            }
            TIdentity identity7 = this.Identity;

            base.WriteError(new UnknownRequestIndexPermanentException(identity7.IndexToUse.ToString()), ErrorCategory.InvalidArgument, this.Identity);
            return(null);
        }
Exemplo n.º 10
0
        protected IEnumerable <TObject> GetDataObjects <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where TObject : IConfigurable, new()
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            notFoundReason = null;
            base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(id, session ?? this.DataSession, typeof(TObject), rootID));
            IEnumerable <TObject> objects;

            try
            {
                objects = id.GetObjects <TObject>(rootID, session ?? this.DataSession, optionalData, out notFoundReason);
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(session ?? this.DataSession));
            }
            return(objects);
        }
Exemplo n.º 11
0
        private IEnumerable <TResult> ResolveIdList <TObject, TResult>(IEnumerable idParameters, IConfigDataProvider session, ObjectId rootId, OptionalIdentityData optionalData, ExchangeErrorCategory errorCategory, Func <IIdentityParameter, LocalizedString> parameterToNotFoundError, Func <IIdentityParameter, LocalizedString> parameterToMultipleFoundError, Func <IConfigurable, TResult> convertToResult, Func <IConfigurable, IConfigurable> validateObject) where TObject : IConfigurable, new()
        {
            Func <IConfigurable, TResult>            func       = null;
            Func <IConfigurable, IConfigurable>      func2      = null;
            Dictionary <TResult, IIdentityParameter> dictionary = new Dictionary <TResult, IIdentityParameter>();

            if (idParameters != null)
            {
                if (convertToResult == null)
                {
                    if (func == null)
                    {
                        func = ((IConfigurable obj) => (TResult)((object)obj.Identity));
                    }
                    convertToResult = func;
                }
                if (validateObject == null)
                {
                    if (func2 == null)
                    {
                        func2 = ((IConfigurable obj) => obj);
                    }
                    validateObject = func2;
                }
                foreach (object obj2 in idParameters)
                {
                    IIdentityParameter identityParameter  = (IIdentityParameter)obj2;
                    LocalizedString?   notFoundError      = (parameterToNotFoundError == null) ? null : new LocalizedString?(parameterToNotFoundError(identityParameter));
                    LocalizedString?   multipleFoundError = (parameterToMultipleFoundError == null) ? null : new LocalizedString?(parameterToMultipleFoundError(identityParameter));
                    IConfigurable      arg = this.GetDataObject <TObject>(identityParameter, session, rootId, notFoundError, multipleFoundError);
                    arg = validateObject(arg);
                    TResult tresult = convertToResult(arg);
                    if (dictionary.ContainsKey(tresult))
                    {
                        throw new ManagementObjectDuplicateException(Strings.ErrorDuplicateManagementObjectFound(dictionary[tresult], identityParameter, tresult));
                    }
                    dictionary.Add(tresult, identityParameter);
                }
            }
            return(dictionary.Keys);
        }
Exemplo n.º 12
0
        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));
        }
        // Token: 0x06001657 RID: 5719 RVA: 0x000544FC File Offset: 0x000526FC
        public static bool TryDecodeIIdentityParameter(IIdentityParameter identity, out IIdentityParameter decodedIdentity)
        {
            decodedIdentity = null;
            if (identity == null)
            {
                return(false);
            }
            string rawIdentity = identity.RawIdentity;

            if (string.IsNullOrWhiteSpace(rawIdentity))
            {
                return(false);
            }
            Type   type = identity.GetType();
            string text;

            if (!UrlTokenConverter.TryUrlTokenDecode(rawIdentity, out text))
            {
                return(false);
            }
            try
            {
                decodedIdentity = (Activator.CreateInstance(type, new object[]
                {
                    text
                }) as IIdentityParameter);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }
            catch (MissingMethodException arg)
            {
                throw new InvalidOperationException(string.Format("DEV Bug: The type {0} must have ctor(string) in order to be parsed from string input. Exception: {1}", type, arg));
            }
            return(decodedIdentity != null);
        }
Exemplo n.º 14
0
        protected IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, OptionalIdentityData optionalData, LocalizedString notFoundError, LocalizedString multipleFoundError) where TObject : IConfigurable, new()
        {
            IConfigurable         result          = null;
            LocalizedString?      localizedString = null;
            IEnumerable <TObject> objects         = id.GetObjects <TObject>(rootID, session, optionalData, out localizedString);

            using (IEnumerator <TObject> enumerator = objects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    result = enumerator.Current;
                    if (enumerator.MoveNext())
                    {
                        Exception innerException = new ManagementObjectAmbiguousException(multipleFoundError);
                        base.WriteError(new TaskInvalidOperationException(multipleFoundError, innerException), ExchangeErrorCategory.Client, this.Identity);
                    }
                }
                else
                {
                    LocalizedString message;
                    if (localizedString != null)
                    {
                        string          notFound         = notFoundError;
                        LocalizedString?localizedString2 = localizedString;
                        message = Strings.ErrorNotFoundWithReason(notFound, (localizedString2 != null) ? localizedString2.GetValueOrDefault() : null);
                    }
                    else
                    {
                        message = notFoundError;
                    }
                    Exception innerException = new ManagementObjectNotFoundException(message);
                    base.WriteError(new TaskInvalidOperationException(notFoundError, innerException), ExchangeErrorCategory.Client, this.Identity);
                }
            }
            return(result);
        }
Exemplo n.º 15
0
 internal IEnumerable <T> GetAdDataObjects <T>(IIdentityParameter id, IConfigDataProvider session) where T : IConfigurable, new()
 {
     return(base.GetDataObjects <T>(id, session, null));
 }
Exemplo n.º 16
0
 internal IConfigurable GetAdDataObject <T>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootId, LocalizedString?notFoundError, LocalizedString?multipleFoundError) where T : IConfigurable, new()
 {
     return(base.GetDataObject <T>(id, session, rootId, notFoundError, multipleFoundError));
 }
 T IPFTreeTask.GetDataObject <T>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, LocalizedString?notFoundError, LocalizedString?multipleFoundError)
 {
     return((T)((object)base.GetDataObject <T>(id, session, rootID, notFoundError, multipleFoundError)));
 }
Exemplo n.º 18
0
 public static LocalizedString GetFindByIdParameterVerboseString(IIdentityParameter id, IConfigDataProvider session, Type type, ObjectId rootId)
 {
     return(Strings.VerboseTaskGetDataObjects(id.ToString(), type.Name, (rootId == null) ? "$null" : rootId.ToString()));
 }
Exemplo n.º 19
0
 protected IConfigurable GetDataObject(IIdentityParameter id)
 {
     return(this.GetDataObject <TDataObject>(id, this.DataSession, this.RootId, null, null, null));
 }
Exemplo n.º 20
0
 protected new IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, LocalizedString?notFoundError, LocalizedString?multipleFoundError) where TObject : IConfigurable, new()
 {
     return(base.GetDataObject <TObject>(id, session, rootID, null, notFoundError, multipleFoundError));
 }
Exemplo n.º 21
0
 protected IConfigurable GetDataObject <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID, LocalizedString?notFoundError, LocalizedString?multipleFoundError, ExchangeErrorCategory errorCategory) where TObject : IConfigurable, new()
 {
     return(this.GetDataObject <TObject>(id, session, rootID, null, notFoundError, multipleFoundError, errorCategory));
 }
Exemplo n.º 22
0
        protected void ResolveDatabaseAndServer()
        {
            DatabaseIdParameter databaseIdParameter   = this.Database;
            ServerIdParameter   serverIdParameter     = this.Server ?? new ServerIdParameter();
            ActiveManager       activeManagerInstance = ActiveManager.GetActiveManagerInstance();

            if (this.Identity != null)
            {
                bool flag = false;
                if (this.isRunningLogonStatisticsTask)
                {
                    TIdentity tidentity            = this.Identity;
                    IEnumerable <Database> objects = tidentity.GetObjects <Database>(null, base.GlobalConfigSession);
                    foreach (Database item in objects)
                    {
                        this.databases.Add(item);
                    }
                    if (this.databases.Count > 0)
                    {
                        if (this.databases[0].Server == null)
                        {
                            string    name       = typeof(Database).Name;
                            TIdentity tidentity2 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name, tidentity2.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.databases[0].Guid);
                        serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                        if (string.IsNullOrEmpty(this.databases[0].ExchangeLegacyDN))
                        {
                            string    name2      = typeof(Database).Name;
                            TIdentity tidentity3 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name2, tidentity3.ToString(), DatabaseSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        this.identity = new MailboxId(this.databases[0].ExchangeLegacyDN);
                        flag          = true;
                    }
                }
                if (!flag)
                {
                    IIdentityParameter  id            = this.Identity;
                    IConfigDataProvider session       = this.readOnlyRecipientSession;
                    ObjectId            rootID        = null;
                    TIdentity           tidentity4    = this.Identity;
                    LocalizedString?    notFoundError = new LocalizedString?(Strings.ErrorMailboxNotFound(tidentity4.ToString()));
                    TIdentity           tidentity5    = this.Identity;
                    ADRecipient         adrecipient   = (ADRecipient)base.GetDataObject <ADRecipient>(id, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorMailboxNotUnique(tidentity5.ToString())));
                    Guid       guid = Guid.Empty;
                    string     mailboxExchangeLegacyDn = null;
                    ADObjectId adobjectId = null;
                    if (string.IsNullOrEmpty(adrecipient.LegacyExchangeDN))
                    {
                        string    name3      = typeof(ADRecipient).Name;
                        TIdentity tidentity6 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name3, tidentity6.ToString(), ADRecipientSchema.LegacyExchangeDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
                    }
                    ADUser                   aduser                   = adrecipient as ADUser;
                    ADSystemMailbox          adsystemMailbox          = adrecipient as ADSystemMailbox;
                    ADSystemAttendantMailbox adsystemAttendantMailbox = adrecipient as ADSystemAttendantMailbox;
                    ADPublicDatabase         adpublicDatabase         = adrecipient as ADPublicDatabase;
                    if (aduser != null)
                    {
                        if (this.isRunningMailboxStatisticsTask && aduser.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox && !this.GetAuditLogMailboxStatistics())
                        {
                            TIdentity tidentity7 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.RecipientNotFoundException(tidentity7.ToString())), ErrorCategory.InvalidArgument, null);
                        }
                        bool archiveMailboxStatistics = this.GetArchiveMailboxStatistics();
                        if (aduser.RecipientType == RecipientType.MailUser && !archiveMailboxStatistics)
                        {
                            base.WriteError(new MdbAdminTaskException(Strings.RecipientTypeNotValid(aduser.ToString())), (ErrorCategory)1003, this.Identity);
                        }
                        RecipientIdParameter recipientIdParameter = this.Identity as RecipientIdParameter;
                        if (this.isRunningMailboxStatisticsTask && recipientIdParameter != null && recipientIdParameter.RawMailboxGuidInvolvedInSearch != Guid.Empty && aduser.MailboxLocations != null)
                        {
                            IMailboxLocationInfo mailboxLocation = aduser.MailboxLocations.GetMailboxLocation(recipientIdParameter.RawMailboxGuidInvolvedInSearch);
                            if (mailboxLocation != null)
                            {
                                guid       = mailboxLocation.MailboxGuid;
                                adobjectId = mailboxLocation.DatabaseLocation;
                            }
                        }
                        if (guid == Guid.Empty || adobjectId == null)
                        {
                            if (archiveMailboxStatistics)
                            {
                                if (aduser.ArchiveGuid != Guid.Empty)
                                {
                                    if (aduser.ArchiveDomain != null)
                                    {
                                        base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(aduser.ToString())), (ErrorCategory)1003, this.Identity);
                                    }
                                    else
                                    {
                                        guid       = aduser.ArchiveGuid;
                                        adobjectId = (aduser.ArchiveDatabase ?? aduser.Database);
                                    }
                                }
                                else
                                {
                                    base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Identity);
                                }
                            }
                            else
                            {
                                guid       = aduser.ExchangeGuid;
                                adobjectId = aduser.Database;
                            }
                        }
                        mailboxExchangeLegacyDn = aduser.LegacyExchangeDN;
                    }
                    else if (adsystemMailbox != null)
                    {
                        guid = adsystemMailbox.ExchangeGuid;
                        mailboxExchangeLegacyDn = adsystemMailbox.LegacyExchangeDN;
                        adobjectId = adsystemMailbox.Database;
                    }
                    else if (adsystemAttendantMailbox != null)
                    {
                        guid = adsystemAttendantMailbox.Guid;
                        mailboxExchangeLegacyDn = adsystemAttendantMailbox.LegacyExchangeDN;
                        adobjectId = adsystemAttendantMailbox.Database;
                    }
                    else if (adpublicDatabase != null)
                    {
                        mailboxExchangeLegacyDn = adpublicDatabase.LegacyExchangeDN;
                        adobjectId = (ADObjectId)adpublicDatabase.Identity;
                    }
                    if (adobjectId == null)
                    {
                        string    name4      = adrecipient.GetType().Name;
                        TIdentity tidentity8 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name4, tidentity8.ToString(), IADMailStorageSchema.Database.Name)), ErrorCategory.InvalidArgument, adrecipient);
                    }
                    databaseIdParameter = new DatabaseIdParameter(adobjectId);
                    if (this.isRunningLogonStatisticsTask)
                    {
                        this.identity = new MailboxId(mailboxExchangeLegacyDn);
                    }
                    else
                    {
                        this.identity = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid);
                    }
                }
            }
            if (databaseIdParameter != null)
            {
                databaseIdParameter.AllowLegacy = true;
                LocalizedString empty  = LocalizedString.Empty;
                LocalizedString empty2 = LocalizedString.Empty;
                Database        database;
                if (this.isRunningLogonStatisticsTask)
                {
                    database = (Database)base.GetDataObject <Database>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString())));
                }
                else
                {
                    database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(databaseIdParameter.ToString())));
                }
                if (database.Server == null)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(this.isRunningLogonStatisticsTask ? typeof(Database).Name : typeof(MailboxDatabase).Name, databaseIdParameter.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database);
                }
                this.databases = new List <Database>(new Database[]
                {
                    database
                });
                if (this.CopyOnServer != null)
                {
                    serverIdParameter = this.CopyOnServer;
                }
                else
                {
                    DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(database.Guid);
                    serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                }
            }
            if (this.Server != null)
            {
                serverIdParameter = this.Server;
                this.server       = MapiTaskHelper.GetMailboxServer(this.Server, base.GlobalConfigSession, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            else
            {
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter, base.GlobalConfigSession, null, new LocalizedString?((this.Identity == null && this.Database == null) ? Strings.ErrorLocalMachineIsNotExchangeServer : Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    if (this.Identity != null)
                    {
                        TIdentity tidentity9 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorMailboxInNonMailboxServer(tidentity9.ToString())), ErrorCategory.InvalidArgument, this.server);
                    }
                    if (this.Database != null)
                    {
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorDatabaseInNonMailboxServer(this.Database.ToString())), ErrorCategory.InvalidArgument, this.server);
                    }
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
            }
            if (string.IsNullOrEmpty(this.server.ExchangeLegacyDN))
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, serverIdParameter.ToString(), ServerSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
            }
            if (this.databases.Count == 0)
            {
                if (this.isRunningLogonStatisticsTask)
                {
                    this.FilterActiveDatabases(activeManagerInstance, this.server.GetDatabases());
                    return;
                }
                this.FilterActiveDatabases(activeManagerInstance, this.server.GetMailboxDatabases());
            }
        }
Exemplo n.º 23
0
        protected IEnumerable <TObject> GetDataObjects <TObject>(IIdentityParameter id, IConfigDataProvider session, ObjectId rootID) where TObject : IConfigurable, new()
        {
            LocalizedString?localizedString;

            return(this.GetDataObjects <TObject>(id, session, rootID, null, out localizedString));
        }
Exemplo n.º 24
0
        protected IEnumerable <TDataObject> GetDataObjects(IIdentityParameter id)
        {
            LocalizedString?localizedString;

            return(this.GetDataObjects <TDataObject>(id, this.DataSession, this.RootId, null, out localizedString));
        }
Exemplo n.º 25
0
 protected IEnumerable <TDataObject> GetDataObjects(IIdentityParameter id, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
 {
     return(this.GetDataObjects <TDataObject>(id, this.DataSession, this.RootId, optionalData, out notFoundReason));
 }
 protected override void ResolveCurrentOrgIdBasedOnIdentity(IIdentityParameter identity)
 {
     base.ResolveCurrentOrgIdBasedOnIdentity(identity);
     Utils.ValidateNotForestWideOrganization(base.CurrentOrganizationId);
 }
Exemplo n.º 27
0
        private void AssignDirectoryIdentity <TObject>(IIdentityParameter identityParameter, DirectoryObjectType objectType, LocalizedString notFoundErrorMsg, LocalizedString ambiguousObjErrorMsg) where TObject : ADConfigurationObject, new()
        {
            ADConfigurationObject adconfigurationObject = (ADConfigurationObject)base.GetDataObject <TObject>(identityParameter, this.ConfigurationSession, this.RootId, new LocalizedString?(notFoundErrorMsg), new LocalizedString?(ambiguousObjErrorMsg));

            this.objectIdentity = DirectoryIdentity.CreateFromADObjectId(adconfigurationObject.Id, objectType);
        }
Exemplo n.º 28
0
        public static ADUser ResolveADUser(IRecipientSession dataSession, IRecipientSession globalCatalogSession, ADServerSettings serverSettings, IIdentityParameter identity, OptionalIdentityData optionalData, string domainController, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObjectHandler, Task.TaskVerboseLoggingDelegate logHandler, Task.ErrorLoggerDelegate errorHandler, bool checkScopes)
        {
            ADUser           aduser = (ADUser)RecipientTaskHelper.ResolveDataObject <ADUser>(dataSession, globalCatalogSession, serverSettings, identity, null, optionalData, domainController, getDataObjectHandler, logHandler, errorHandler);
            ADScopeException exception;

            if (checkScopes && !dataSession.TryVerifyIsWithinScopes(aduser, true, out exception))
            {
                errorHandler(exception, (ExchangeErrorCategory)5, identity);
            }
            return(aduser);
        }
Exemplo n.º 29
0
        internal static IConfigurable ResolveDataObject(IConfigDataProvider readOnlySession, IConfigDataProvider readOnlyConfigurationSession, IConfigDataProvider globalCatalogSession, IIdentityParameter identity, DataAccessHelper.GetDataObjectDelegate getDataObjectHandler, Task.TaskVerboseLoggingDelegate logHandler)
        {
            IConfigurable configurable   = null;
            ADObjectId    adobjectId     = null;
            ADObjectId    rootID         = RecipientTaskHelper.IsValidDistinguishedName(identity, out adobjectId) ? adobjectId.Parent : null;
            Exception     innerException = null;

            if (readOnlySession != null)
            {
                try
                {
                    configurable = getDataObjectHandler(identity, readOnlySession, rootID, null, null, new LocalizedString?(Strings.ErrorObjectNotUnique(identity.ToString())));
                }
                catch (ADTransientException ex)
                {
                    innerException = ex;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlySession.Source, ex.Message));
                }
                catch (ManagementObjectNotFoundException ex2)
                {
                    innerException = ex2;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlySession.Source, ex2.Message));
                }
            }
            if (configurable == null && readOnlyConfigurationSession != null)
            {
                try
                {
                    configurable = getDataObjectHandler(identity, readOnlyConfigurationSession, rootID, null, null, new LocalizedString?(Strings.ErrorObjectNotUnique(identity.ToString())));
                }
                catch (ADTransientException ex3)
                {
                    innerException = ex3;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlyConfigurationSession.Source, ex3.Message));
                }
                catch (ManagementObjectNotFoundException ex4)
                {
                    innerException = ex4;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlyConfigurationSession.Source, ex4.Message));
                }
            }
            if (configurable == null && globalCatalogSession != null)
            {
                try
                {
                    configurable = getDataObjectHandler(identity, globalCatalogSession, rootID, null, null, new LocalizedString?(Strings.ErrorObjectNotUnique(identity.ToString())));
                }
                catch (ADTransientException ex5)
                {
                    innerException = ex5;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), globalCatalogSession.Source, ex5.Message));
                }
                catch (ManagementObjectNotFoundException ex6)
                {
                    innerException = ex6;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), globalCatalogSession.Source, ex6.Message));
                }
            }
            if (configurable == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(identity.ToString()), innerException);
            }
            return(configurable);
        }
Exemplo n.º 30
0
        // Token: 0x06000452 RID: 1106 RVA: 0x0000F624 File Offset: 0x0000D824
        internal static OrganizationIdParameter ResolveTargetOrganizationIdParameter(OrganizationIdParameter organizationParameter, IIdentityParameter identity, OrganizationId currentOrganizationId, Task.ErrorLoggerDelegate errorHandler, Task.TaskWarningLoggingDelegate warningHandler)
        {
            OrganizationIdParameter organizationIdParameter = null;

            if (identity != null)
            {
                if (identity is MailPublicFolderIdParameter)
                {
                    organizationIdParameter = (identity as MailPublicFolderIdParameter).Organization;
                }
                else if (identity is PublicFolderIdParameter)
                {
                    organizationIdParameter = (identity as PublicFolderIdParameter).Organization;
                }
            }
            if (!currentOrganizationId.Equals(OrganizationId.ForestWideOrgId))
            {
                if (organizationIdParameter != null)
                {
                    errorHandler(new ManagementObjectNotFoundException(Strings.ErrorManagementObjectNotFound(identity.ToString())), ExchangeErrorCategory.Client, identity);
                }
            }
            else
            {
                if (organizationParameter != null)
                {
                    if (organizationIdParameter != null)
                    {
                        warningHandler(Strings.WarningDuplicateOrganizationSpecified(organizationParameter.ToString(), organizationIdParameter.ToString()));
                    }
                    organizationIdParameter = organizationParameter;
                }
                if (organizationIdParameter == null && !(identity is MailPublicFolderIdParameter))
                {
                    errorHandler(new ErrorMissOrganizationException(), ExchangeErrorCategory.Client, null);
                }
            }
            return(organizationIdParameter);
        }