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); }
public static LocalizedString GetFindByIdParameterVerboseString(IIdentityParameter id, IConfigDataProvider session, Type type, ObjectId rootId) { return(Strings.VerboseTaskGetDataObjects(id.ToString(), type.Name, (rootId == null) ? "$null" : rootId.ToString())); }
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); }
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); }
// 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); }