public static RemoteSiteInCurrentOrgTrackingAuthority Create(ADObjectId siteADObjectId, DirectoryContext directoryContext, int minServerVersionRequested, bool useServersCache) { string text = ServerCache.Instance.GetDefaultDomain(directoryContext.OrganizationId); int version = 0; Uri uri = null; if (useServersCache) { TraceWrapper.SearchLibraryTracer.TraceDebug <ADObjectId>(0, "Creating remote tracking authority via ServersCache for site: {0}", siteADObjectId); try { MiniServer anyBackEndServerFromASite = ServersCache.GetAnyBackEndServerFromASite(siteADObjectId, minServerVersionRequested, false); version = anyBackEndServerFromASite.VersionNumber; TraceWrapper.SearchLibraryTracer.TraceDebug <string, ServerVersion>(0, "Found remote server {0} running {1}.", anyBackEndServerFromASite.Fqdn, anyBackEndServerFromASite.AdminDisplayVersion); if (anyBackEndServerFromASite.MajorVersion >= 15) { BackEndServer backEndServer = new BackEndServer(anyBackEndServerFromASite.Fqdn, version); uri = BackEndLocator.GetBackEndWebServicesUrl(backEndServer); } else { TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Server found was E14, finding new tracking authority via ServiceTopology.", new object[0]); uri = ServerCache.Instance.GetCasServerUri(siteADObjectId, minServerVersionRequested, out version); } goto IL_118; } catch (BackEndLocatorException ex) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Failed to acquire EWS URI from BackEndLocator with exception: {0}", ex.ToString()); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); goto IL_118; } catch (ServerHasNotBeenFoundException ex2) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Failed to locate remote backend server from ServersCache with exception: {0}", ex2.ToString()); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); goto IL_118; } } TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Creating remote tracking authority via ServiceTopology.", new object[0]); uri = ServerCache.Instance.GetCasServerUri(siteADObjectId, minServerVersionRequested, out version); IL_118: if (null == uri) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No suitable authority URI found.", new object[0]); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); } return(new RemoteSiteInCurrentOrgTrackingAuthority(text, TrackingAuthorityKind.RemoteSiteInCurrentOrg, siteADObjectId, uri, version)); }
internal static void UpdateServerLegdnForDatabaseSite(Task.TaskErrorLoggingDelegate writeErrorDelegate, Task.TaskVerboseLoggingDelegate writeVerboseDelegate, ITopologyConfigurationSession adSession, DatabaseCopy dbCopy) { ADObjectId hostServer = dbCopy.HostServer; PropertyDefinition[] properties = new PropertyDefinition[] { ServerSchema.ServerSite }; MiniServer miniServer = adSession.ReadMiniServer(hostServer, properties); if (miniServer == null) { writeErrorDelegate(new ADServerNotFoundException(hostServer.ToString()), ErrorCategory.InvalidArgument, null); } IADToplogyConfigurationSession adSession2 = ADSessionFactory.CreateWrapper(adSession); SimpleAdObjectLookup <IADClientAccessArray> findClientAccessArray = new SimpleAdObjectLookup <IADClientAccessArray>(adSession2); SimpleMiniClientAccessServerOrArrayLookup findMiniClientAccessServer = new SimpleMiniClientAccessServerOrArrayLookup(adSession); ADObjectId serverSite = miniServer.ServerSite; LegacyDN legacyDN = ActiveManagerImplementation.FindClientAccessArrayOrServerFromSite(serverSite, miniServer.Id, findClientAccessArray, findMiniClientAccessServer, AdObjectLookupFlags.ReadThrough); ADObjectId parent = dbCopy.Id.Parent; Database database = adSession.Read <Database>(parent); if (legacyDN != null) { LegacyDN databaseLegacyDNFromRcaLegacyDN = Database.GetDatabaseLegacyDNFromRcaLegacyDN(legacyDN, database.IsPublicFolderDatabase); database.ExchangeLegacyDN = databaseLegacyDNFromRcaLegacyDN.ToString(); writeVerboseDelegate(Strings.UpdatingLegDnForDatabaseToServer(database.Name, legacyDN.ToString(), legacyDN.ToString())); adSession.Save(database); return; } ExTraceGlobals.CmdletsTracer.TraceDebug <ADObjectId>(0L, "Could not find a new CAS machines for site '{0}'. Leaving the database's legdn unchanged.", serverSite); }
internal static UMAutoAttendant FindAutoAttendantByPilotIdentifierAndDialPlan(string pilotIdentifier, ADObjectId dialPlanId) { if (pilotIdentifier == null) { throw new ArgumentNullException("pilotIdentifier"); } if (dialPlanId == null) { throw new ArgumentNullException("dialPlanId"); } ADSessionSettings sessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(dialPlanId); IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 2144, "FindAutoAttendantByPilotIdentifierAndDialPlan", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\umautoattendantconfig.cs"); QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, UMAutoAttendantSchema.PilotIdentifierList, pilotIdentifier), new ComparisonFilter(ComparisonOperator.Equal, UMAutoAttendantSchema.UMDialPlan, dialPlanId) }); UMAutoAttendant[] array = tenantOrTopologyConfigurationSession.Find <UMAutoAttendant>(null, QueryScope.SubTree, filter, null, 0); switch (array.Length) { case 0: return(null); case 1: return(array[0]); default: throw new NonUniquePilotIdentifierException(pilotIdentifier, dialPlanId.ToString()); } }
private void WriteResult(ADObjectId member, DelegateRoleType role, string scope) { string text = Strings.OrganizationWide.ToString(); DelegateUser sendToPipeline = new DelegateUser(member.ToString(), role, (role != DelegateRoleType.ServerAdmin) ? text : scope); base.WriteObject(sendToPipeline); }
private static OrganizationalUnitPickerService.OUElement BuildOUTree(DataTable dataTable) { Dictionary <string, OrganizationalUnitPickerService.OUElement> dictionary = new Dictionary <string, OrganizationalUnitPickerService.OUElement>(); OrganizationalUnitPickerService.OUElement ouelement = new OrganizationalUnitPickerService.OUElement(); ouelement.ID = (ouelement.Name = "root"); ouelement.CanNewSubNode = false; dictionary.Add(ouelement.Name, ouelement); foreach (object obj in dataTable.Rows) { DataRow dataRow = (DataRow)obj; ADObjectId adobjectId = (ADObjectId)dataRow["Identity"]; string text = adobjectId.ToString(); int num = OrganizationalUnitPickerService.LastSplitCharPosition(text); string key = (num == -1) ? ouelement.Name : text.Substring(0, num); if (dictionary.ContainsKey(key)) { OrganizationalUnitPickerService.OUElement ouelement2 = new OrganizationalUnitPickerService.OUElement(); ouelement2.ID = adobjectId.ObjectGuid.ToString(); ouelement2.CanNewSubNode = false; ouelement2.Name = text.Substring(num + 1); dictionary[key].Children.Add(ouelement2); dictionary.Add(text, ouelement2); } } return(ouelement); }
protected virtual object GetIdentityFromObject(object newObject) { object obj = null; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(newObject); PropertyDescriptor propertyDescriptor = null; if (!string.IsNullOrEmpty(this.ListControl.IdentityProperty)) { propertyDescriptor = properties[this.ListControl.IdentityProperty]; } propertyDescriptor = (propertyDescriptor ?? properties["Identity"]); if (propertyDescriptor != null) { obj = propertyDescriptor.GetValue(newObject); ADObjectId adobjectId = obj as ADObjectId; if (adobjectId != null) { obj = new object[] { adobjectId, adobjectId.DistinguishedName, adobjectId.ToString(), adobjectId.ObjectGuid.ToString() }; } else if (obj is Guid) { obj = ((Guid)obj).ToString(); } } return(obj); }
public void RemoveOutboundConnector(ADObjectId identity) { SessionParameters sessionParameters = new SessionParameters(); sessionParameters.Set("Identity", identity.ToString()); sessionParameters.Set("Confirm", false); base.RemotePowershellSession.RunOneCommand("Remove-OutboundConnector", sessionParameters, false); }
public InboxRuleIdParameter(ADObjectId mailboxOwnerId) { if (mailboxOwnerId == null) { throw new ArgumentNullException("mailboxOwnerId"); } this.rawInput = mailboxOwnerId.ToString(); ((IIdentityParameter)this).Initialize(new InboxRuleId(mailboxOwnerId, null, null)); }
public MailboxFolderIdParameter(ADObjectId mailboxOwnerId) { if (mailboxOwnerId == null) { throw new ArgumentNullException("mailboxOwnerId"); } this.rawIdentity = mailboxOwnerId.ToString(); ((IIdentityParameter)this).Initialize(new MailboxFolderId(mailboxOwnerId, null, MapiFolderPath.IpmSubtreeRoot)); }
// Token: 0x06000C2F RID: 3119 RVA: 0x00026614 File Offset: 0x00024814 public MessageCategoryIdParameter(ADObjectId mailboxOwnerId) { if (mailboxOwnerId == null) { throw new ArgumentNullException("mailboxOwnerId"); } ((IIdentityParameter)this).Initialize(new MessageCategoryId(mailboxOwnerId, null, null)); this.rawInput = mailboxOwnerId.ToString(); }
public UMCallAnsweringRuleIdParameter(ADObjectId mailboxOwnerId) { if (mailboxOwnerId == null) { throw new ArgumentNullException("mailboxOwnerId"); } this.rawInput = mailboxOwnerId.ToString(); ((IIdentityParameter)this).Initialize(new UMCallAnsweringRuleId(mailboxOwnerId, Guid.Empty)); }
public MailboxStoreIdParameter(ADObjectId objectId) { if (objectId == null) { throw new ArgumentNullException("objectId"); } this.rawIdentity = objectId.ToString(); this.name = objectId.Name; }
internal static ADObjectId GetExecutingUserAndCheckGroupOwnership(Task task, IDirectorySession dataSession, IRecipientSession gcSession, ADGroup group, bool bypassSecurityGroupManagerCheck) { ADScopeException ex2 = null; ADObjectId adobjectId = null; bool flag = task.TryGetExecutingUserId(out adobjectId); LocalizedException ex = null; ExchangeErrorCategory errCategory = ExchangeErrorCategory.Client; object targetObj = null; bool flag2 = false; if (flag && adobjectId != null && !dataSession.TryVerifyIsWithinScopes(group, true, out ex2)) { task.WriteVerbose(Strings.VerboseDGOwnershipDeepSearch(adobjectId.ToString(), group.Identity.ToString())); RecipientTaskHelper.ValidateUserIsGroupManager(adobjectId, group, delegate(LocalizedException exception, ExchangeErrorCategory category, object target) { ex = exception; errCategory = category; targetObj = target; }, true, gcSession); flag2 = true; group.IsExecutingUserGroupOwner = (ex == null); } if (RecipientType.MailUniversalSecurityGroup == group.RecipientType && !bypassSecurityGroupManagerCheck) { if (!flag) { task.WriteError(new RecipientTaskException(Strings.ErrorExecutingUserOutOfTargetOrg(task.MyInvocation.MyCommand.Name)), ExchangeErrorCategory.Client, group.Identity.ToString()); } if (!flag2) { task.WriteVerbose(Strings.VerboseDGOwnershipDeepSearch(adobjectId.ToString(), group.Identity.ToString())); RecipientTaskHelper.ValidateUserIsGroupManager(adobjectId, group, new Task.ErrorLoggerDelegate(task.WriteError), true, gcSession); group.IsExecutingUserGroupOwner = true; } else if (ex != null) { task.WriteError(ex, errCategory, targetObj); } } group.propertyBag.ResetChangeTracking(ADGroupSchema.IsExecutingUserGroupOwner); return(adobjectId); }
private void CleanupADEntry(ADObjectId userId, ADUser adUser) { base.WriteVerbose(Strings.RemovingMoveJobFromAd(userId.ToString())); try { CommonUtils.CleanupMoveRequestInAD(base.WriteableSession, userId, adUser); } catch (UnableToReadADUserException) { base.WriteVerbose(Strings.UserNotInAd); } }
internal ADUser ReadADUser(ADObjectId userId, Guid exchangeGuid) { if (userId == null) { return(null); } ADRecipient adrecipient = this.Read <ADRecipient>(delegate(IRecipientSession session) { if (CommonUtils.IsMultiTenantEnabled() && exchangeGuid != Guid.Empty && !userId.GetPartitionId().Equals(this.RecipientSession.SessionSettings.PartitionId)) { return(session.FindByExchangeGuidIncludingArchive(exchangeGuid)); } return(session.Read(userId)); }); if (adrecipient == null) { MrsTracer.Common.Warning("No ADRecipient found with Identity '{0}' in organizaton '{1}'.", new object[] { userId.ToString(), this.orgId.ToString() }); return(null); } ADUser aduser = adrecipient as ADUser; if (aduser == null) { MrsTracer.Common.Warning("'{0}' is not a user.", new object[] { userId.ToString() }); return(null); } return(aduser); }
public Uri GetCasServerUri(ADObjectId site, int minServerVersionRequested, out int serverVersion) { SortedDictionary <int, List <WebServicesService> > uriVersions = null; serverVersion = 0; try { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 673); currentServiceTopology.ForEach <WebServicesService>(delegate(WebServicesService service) { if (service.ServerVersionNumber >= minServerVersionRequested && service.Site.Id.Equals(site) && service.ClientAccessType == ClientAccessType.InternalNLBBypass) { if (uriVersions == null) { uriVersions = new SortedDictionary <int, List <WebServicesService> >(); } int key2 = service.ServerVersionNumber >> 16; if (!uriVersions.ContainsKey(key2)) { uriVersions[key2] = new List <WebServicesService>(); } uriVersions[key2].Add(service); } }, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 674); } catch (ServiceDiscoveryTransientException ex) { TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryTransientException>(this.GetHashCode(), "Transient exception getting Internal CAS URI: {0}", ex); TrackingTransientException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex.ToString()); } catch (ServiceDiscoveryPermanentException ex2) { TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryPermanentException>(this.GetHashCode(), "Permanent exception getting Internal CAS URI: {0}", ex2); TrackingFatalException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex2.ToString()); } if (uriVersions != null && uriVersions.Count > 0) { int key = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Key; List <WebServicesService> value = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Value; int index = ServerCache.rand.Next(value.Count); WebServicesService webServicesService = value.ElementAt(index); TraceWrapper.SearchLibraryTracer.TraceDebug <Uri, string>(this.GetHashCode(), "Using CAS URI: {0}, Version {1}", webServicesService.Url, new ServerVersion(webServicesService.ServerVersionNumber).ToString()); serverVersion = webServicesService.ServerVersionNumber; return(webServicesService.Url); } TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Failed to find any CAS server in site: {0}, with min version {1}", site.ToString(), new ServerVersion(minServerVersionRequested).ToString()); return(null); }
public static RemoteSiteInCurrentOrgTrackingAuthority Create(ADObjectId siteADObjectId, DirectoryContext directoryContext, ADUser user) { TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Creating remote tracking authority via BackEndLocator for user.", new object[0]); string text = ServerCache.Instance.GetDefaultDomain(directoryContext.OrganizationId); BackEndServer backEndServer = BackEndLocator.GetBackEndServer(user); Uri backEndWebServicesUrl = BackEndLocator.GetBackEndWebServicesUrl(backEndServer); int version = backEndServer.Version; if (null == backEndWebServicesUrl) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No suitable authority URI found.", new object[0]); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); } TraceWrapper.SearchLibraryTracer.TraceDebug <Uri>(0, "Using EWS URI: {0}", backEndWebServicesUrl); return(new RemoteSiteInCurrentOrgTrackingAuthority(text, TrackingAuthorityKind.RemoteSiteInCurrentOrg, siteADObjectId, backEndWebServicesUrl, version)); }
public Organization GetOrgContainer() { ADObjectId adobjectId = null; if (base.SessionSettings.ConfigReadScope != null) { adobjectId = base.SessionSettings.ConfigReadScope.Root; } Organization[] array; if (adobjectId == null) { if (Globals.IsDatacenter) { Organization organization = (Organization)ADSystemConfigurationSession.GetRootOrgContainer(base.SessionSettings.GetAccountOrResourceForestFqdn(), base.DomainController, base.NetworkCredential).Clone(); organization.SetIsReadOnly(false); organization.m_Session = this; return(organization); } array = base.Find <Organization>(null, QueryScope.SubTree, null, null, 2); } else if (adobjectId.Parent.Parent.Equals(ADSession.GetConfigurationUnitsRoot(base.SessionSettings.GetAccountOrResourceForestFqdn()))) { array = base.Find <ExchangeConfigurationUnit>(adobjectId, QueryScope.Base, null, null, 1); } else { array = base.Find <ExchangeConfigurationUnit>(adobjectId, QueryScope.SubTree, null, null, 2); } if (array == null || array.Length == 0) { if (adobjectId == null) { throw new OrgContainerNotFoundException(); } throw new TenantOrgContainerNotFoundException(adobjectId.ToString()); } else { if (array.Length > 1) { throw new OrgContainerAmbiguousException(); } return(array[0]); } }
private ADGroup GetGroup(ADObjectId groupId) { ADGroup adgroup = this.roleGroups.FirstOrDefault((ADGroup x) => x.Id.Equals(groupId)); if (adgroup == null) { ADRecipient adrecipient = this.recipientSession.Read(groupId); if (adrecipient == null) { this.writeError(new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(groupId.ToString())), ExchangeErrorCategory.Client, null); } adgroup = (adrecipient as ADGroup); if (adgroup == null) { this.writeError(new TaskException(Strings.ErrorObjectNotFound(groupId.ToString())), ExchangeErrorCategory.Client, null); } this.roleGroups.Add(adgroup); } return(adgroup); }
private ADObjectId GetHierarchicalAddressBookRootFromOU(ADObjectId ouId) { if (ouId == null) { return(null); } ExchangeOrganizationalUnit exchangeOrganizationalUnit = (ExchangeOrganizationalUnit)base.GetDataObject <ExchangeOrganizationalUnit>(new OrganizationalUnitIdParameter(ouId), this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOrganizationalUnitNotFound(ouId.ToString())), new LocalizedString?(Strings.ErrorOrganizationalUnitNotUnique(ouId.ToString()))); return(exchangeOrganizationalUnit.HierarchicalAddressBookRoot); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); TDataObject dataObject = this.DataObject; ADObjectId parent = dataObject.Id.Parent; ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(parent); if (!parent.Equals(ADSession.GetRootDomainNamingContext(adsessionSettings.GetAccountOrResourceForestFqdn()))) { IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 264, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs"); tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC; ADRawEntry adrawEntry = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[] { ADObjectSchema.ExchangeVersion, ADObjectSchema.ObjectClass }); if (adrawEntry == null) { if (string.IsNullOrEmpty(base.DomainController)) { TDataObject dataObject2 = this.DataObject; base.WriteError(new TaskException(Strings.ErrorParentNotFound(dataObject2.Name, parent.ToString())), (ErrorCategory)1003, null); } else { TDataObject dataObject3 = this.DataObject; base.WriteError(new TaskException(Strings.ErrorParentNotFoundOnDomainController(dataObject3.Name, base.DomainController, parent.ToString(), parent.DomainId.ToString())), (ErrorCategory)1003, null); } } ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion]; MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass]; TDataObject dataObject4 = this.DataObject; if (dataObject4.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass) && this.EnforceExchangeObjectVersion) { TDataObject dataObject5 = this.DataObject; string name = dataObject5.Name; TDataObject dataObject6 = this.DataObject; base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject6.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null); } } if (base.IsVerboseOn) { base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(this.DataObject)); } base.InternalProcessRecord(); TaskLogger.LogExit(); }
protected override string CheckRequestNameAvailability(string name, ADObjectId identifyingObjectId, bool objectIsMailbox, MRSRequestType requestType, object errorObject, bool wildcardedSearch) { string text = string.Format("{0}*", name); RequestIndexEntryQueryFilter requestIndexEntryQueryFilter = new RequestIndexEntryQueryFilter(wildcardedSearch ? text : name, identifyingObjectId, requestType, new RequestIndexId(RequestIndexLocation.AD), objectIsMailbox); requestIndexEntryQueryFilter.WildcardedNameSearch = wildcardedSearch; ObjectId rootId = ADHandler.GetRootId(base.CurrentOrgConfigSession, requestType); IEnumerable <FolderMoveRequest> enumerable = ((RequestJobProvider)base.DataSession).IndexProvider.FindPaged <FolderMoveRequest>(requestIndexEntryQueryFilter, rootId, rootId == null, null, 10); string result; using (IEnumerator <FolderMoveRequest> enumerator = enumerable.GetEnumerator()) { if (enumerator.MoveNext()) { bool flag = true; while (this.IsNewRequestAllowed(enumerator.Current)) { if (!enumerator.MoveNext()) { IL_93: if (!flag) { base.WriteError(new NameMustBeUniquePermanentException(name, (identifyingObjectId == null) ? string.Empty : identifyingObjectId.ToString()), ErrorCategory.InvalidArgument, errorObject); return(null); } return(name); } } flag = false; goto IL_93; } result = name; } return(result); }
public IADMiniClientAccessServerOrArray FindMiniClientAccessServerOrArrayWithClientAccess(ADObjectId siteId, ADObjectId preferredServerId) { return(this.LookupOrFindMiniClientAccessServerOrArray(string.Format("siteid={0}", siteId.ToString()), delegate { IADMiniClientAccessServerOrArray result = null; Exception ex = ADUtils.RunADOperation(delegate() { result = SimpleMiniClientAccessServerOrArrayLookup.FindMiniCasOrArrayWithClientAccess(this, this.AdSession, siteId, preferredServerId); }, 2); if (ex != null) { MiniClientAccessServerOrArrayLookupCache.Tracer.TraceDebug <Exception>((long)this.GetHashCode(), "MiniClientAccessServerOrArrayLookupCache.ReadMiniClientAccessServerOrArrayByObjectId got an exception: {0}", ex); } return result; })); }
private static string AtomToString(object item) { string text = string.Empty; if (item != null) { if (item is Enum) { text = LocalizedDescriptionAttribute.FromEnum(item.GetType(), item); } else if (item is ADObjectId) { ADObjectId adobjectId = (ADObjectId)item; text = ((!string.IsNullOrEmpty(adobjectId.Name)) ? adobjectId.Name : adobjectId.ToString()); } else if (item is CultureInfo) { text = ((CultureInfo)item).DisplayName; } else if (item is DateTime) { text = ((DateTime)item).ToLongDateString(); } else { text = item.ToString(); } if (string.IsNullOrEmpty(text)) { text = string.Empty; } } return(text); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); bool flag = base.Fields.Contains("SoftDeletedObject"); if (base.IsVerboseOn) { base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.DataObject, base.DataSession, typeof(ADUser))); } if (this.WindowsLiveID != null && this.DataObject.NetID == null) { base.WriteError(new RecipientTaskException(Strings.ErrorMissingWindowsLiveIdHandler), ExchangeErrorCategory.ServerOperation, null); } try { if (base.IsDebugOn) { base.WriteDebug(Strings.DebugStartSaveDataObject); } base.DataSession.Save(this.DataObject); if (base.IsDebugOn) { base.WriteDebug(Strings.DebugEndSaveDataObject); } } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } bool flag2 = false; try { if (!flag) { this.StampChangesBeforeSettingPassword(); if (this.IsSetRandomPassword) { base.WriteVerbose(Strings.VerboseSettingPassword(this.DataObject.Id.ToString())); MailboxTaskHelper.SetMailboxPassword((IRecipientSession)base.DataSession, this.DataObject, null, new Task.ErrorLoggerDelegate(base.WriteError)); } else if (this.Password != null) { base.WriteVerbose(Strings.VerboseSettingPassword(this.DataObject.Id.ToString())); ((IRecipientSession)base.DataSession).SetPassword(this.DataObject, this.Password); } bool flag3 = base.Fields.IsModified(ADUserSchema.PasswordLastSetRaw) ? this.ResetPasswordOnNextLogon : this.DataObject.ResetPasswordOnNextLogon; bool bypassModerationCheck = this.DataObject.BypassModerationCheck; ADObjectId id = this.DataObject.Id; using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "DataSession.Read<ADUser>", LoggerHelper.CmdletPerfMonitors)) { this.DataObject = (ADUser)base.DataSession.Read <ADUser>(this.DataObject.Identity); } if (this.DataObject == null || this.DataObject.Id == null) { string id2 = (id == null) ? string.Empty : id.ToString(); base.WriteError(new RecipientTaskException(Strings.ErrorCreatedUserNotExist(id2)), ExchangeErrorCategory.ServerOperation, null); } this.DataObject.BypassModerationCheck = bypassModerationCheck; this.DataObject[ADUserSchema.PasswordLastSetRaw] = new long?(flag3 ? 0L : -1L); this.StampChangesAfterSettingPassword(); } base.InternalProcessRecord(); flag2 = !base.HasErrors; } finally { if (!flag2 && this.DataObject != null && this.DataObject.Id != null && !flag) { try { base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.DataObject.Id, base.DataSession, typeof(ADUser))); base.DataSession.Delete(this.DataObject); } catch (DataSourceTransientException innerException) { base.WriteError(new RecipientTaskException(Strings.ErrorRemoveUserFailed(this.DataObject.Id.ToString()), innerException), ExchangeErrorCategory.ServerTransient, null); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } } TaskLogger.LogExit(); }
public static AnchorRunspaceProxy CreateRunspaceForDatacenterAdmin(AnchorContext context, ADObjectId ownerId) { AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId"); return(AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(context, ownerId.ToString())); }
public static AnchorRunspaceProxy CreateRunspaceForPartner(AnchorContext context, ADObjectId ownerId, ADUser tenantAdmin, string tenantOrganization) { AnchorUtil.ThrowOnNullArgument(ownerId, "ownerId"); AnchorUtil.ThrowOnNullArgument(tenantAdmin, "tenantAdmin"); AnchorUtil.ThrowOnNullOrEmptyArgument(tenantOrganization, "tenantOrganization"); context.Logger.Log(MigrationEventType.Verbose, "AnchorRunspaceProxy. Creating partner runspace proxy for user {0}", new object[] { tenantAdmin.Name }); ExchangeRunspaceConfigurationSettings configSettings = new ExchangeRunspaceConfigurationSettings(ExchangeRunspaceConfigurationSettings.ExchangeApplication.SimpleDataMigration, tenantOrganization, ExchangeRunspaceConfigurationSettings.GetDefaultInstance().CurrentSerializationLevel); return(new AnchorRunspaceProxy(context, AnchorRunspaceProxy.RunspaceFactoryWithDCAffinity.CreateRbacFactory(context, ownerId.ToString(), new GenericSidIdentity(tenantAdmin.Name, string.Empty, tenantAdmin.Sid), configSettings))); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); ADObjectId adobjectId = null; Guid guid = Guid.Empty; string text = string.Empty; bool flag = this.ShouldSoftDeleteObject(); ADUser dataObject = base.DataObject; if (Globals.IsMicrosoftHostedOnly) { if (flag) { bool flag2 = SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId); bool includeInGarbageCollection = (!flag2 || base.ForReconciliation) && !this.isToInactiveMailbox; SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, includeInGarbageCollection, this.isToInactiveMailbox); } else { if (this.isDisconnectInactiveMailbox) { SoftDeletedTaskHelper.UpdateMailboxForDisconnectInactiveMailbox(dataObject); base.DataSession.Save(dataObject); TaskLogger.LogExit(); this.LogRemoveMailboxDetails(dataObject); return; } dataObject.RecipientSoftDeletedStatus = 0; } } if (this.Identity != null) { adobjectId = base.DataObject.Database; guid = base.DataObject.ExchangeGuid; if (adobjectId == null) { TaskLogger.Trace("The homeMDB is empty for this user, we just try to remove the user AD object", new object[0]); } else if (guid == Guid.Empty) { TaskLogger.Trace("The ExchangeGuid is empty for this user, we just try to remove the user AD object", new object[0]); } else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.MailboxPlan) { TaskLogger.Trace("This user is MailboxPlan, we just try to remove the user AD object", new object[0]); } else if (!flag) { try { DatabaseLocationInfo databaseLocationInfo = null; try { databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(adobjectId.ObjectGuid); } catch (ObjectNotFoundException exception) { base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null); } if (databaseLocationInfo == null) { if (this.Permanent) { base.WriteError(new TaskInvalidOperationException(Strings.ErrorGetServerNameFromMailbox(base.DataObject.Identity.ToString())), ExchangeErrorCategory.ServerOperation, base.DataObject); } else { TaskLogger.Trace("cannot get the server name for mailbox {0}", new object[] { base.DataObject.Identity }); } } else { text = databaseLocationInfo.ServerFqdn; base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(text)); this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(text)); } } catch (MapiPermanentException ex) { if (this.Permanent) { base.WriteError(ex, ExchangeErrorCategory.ServerOperation, this.Identity); } else { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex }); } } catch (MapiRetryableException ex2) { if (this.Permanent) { base.WriteError(ex2, ExchangeErrorCategory.ServerTransient, this.Identity); } else { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex2 }); } } try { if (dataObject != null && base.ForReconciliation) { base.DataObject.ExternalDirectoryObjectId = string.Empty; } base.DataObject.PreviousDatabase = base.DataObject.Database; base.DataSession.Save(base.DataObject); } catch (DataSourceTransientException exception2) { base.WriteError(exception2, ExchangeErrorCategory.ServerTransient, null); } catch (InvalidObjectOperationException) { } catch (DataValidationException) { } catch (ADOperationException) { } } base.InternalProcessRecord(); this.LogRemoveMailboxDetails(dataObject); } if (this.StoreMailboxIdentity != null || this.Permanent) { if (this.Permanent) { if (!(guid != Guid.Empty) || adobjectId == null) { goto IL_5A0; } try { base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(guid.ToString(), adobjectId.ToString())); this.mapiSession.DeleteMailbox(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid)); goto IL_5A0; } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex3) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex3 }); base.WriteVerbose(ex3.LocalizedString); goto IL_5A0; } catch (DataSourceOperationException exception3) { base.WriteError(exception3, ExchangeErrorCategory.ServerOperation, base.DataObject); goto IL_5A0; } } try { base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(this.mailboxStatistics.MailboxGuid.ToString(), this.mailboxStatistics.Database.ToString())); ((IConfigDataProvider)this.mapiSession).Delete(this.mailboxStatistics); goto IL_5A0; } catch (DataSourceOperationException exception4) { base.WriteError(exception4, ExchangeErrorCategory.ServerOperation, (this.Identity == null) ? this.StoreMailboxIdentity : this.Identity); goto IL_5A0; } } if (this.mapiSession != null) { try { TIdentity identity = this.Identity; base.WriteVerbose(Strings.VerboseSyncMailboxWithDS(identity.ToString(), base.DataObject.Database.ToString(), text)); bool flag3 = true; if (base.DataObject.Database == null || Guid.Empty == base.DataObject.Database.ObjectGuid) { flag3 = false; TaskLogger.Trace("Cannot get the database for mailbox '{0}'", new object[] { base.DataObject.Identity }); } if (Guid.Empty == base.DataObject.ExchangeGuid) { flag3 = false; TaskLogger.Trace("Cannot get the mailbox guid for mailbox '{0}'", new object[] { base.DataObject.Identity }); } if (flag3) { this.mapiSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(base.DataObject.Database), base.DataObject.ExchangeGuid)); } } catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex4) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex4 }); base.WriteVerbose(ex4.LocalizedString); } catch (DataSourceTransientException ex5) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex5 }); this.WriteWarning(ex5.LocalizedString); } catch (DataSourceOperationException ex6) { TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[] { ex6 }); this.WriteWarning(ex6.LocalizedString); } } IL_5A0: if (!flag && this.mailboxStatistics != null) { this.mailboxStatistics.Dispose(); this.mailboxStatistics = null; } this.DisposeMapiSession(); TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (!base.HasErrors) { UMDialPlan dialPlan = this.DataObject.GetDialPlan(); if (dialPlan == null) { base.WriteError(new DialPlanNotFoundException(this.DataObject.UMDialPlan.Name), ErrorCategory.NotSpecified, null); } int numberOfDigitsInExtension = dialPlan.NumberOfDigitsInExtension; MultiValuedProperty <string> multiValuedProperty = null; multiValuedProperty = this.DataObject.PilotIdentifierList; if (this.DataObject.IsChanged(UMAutoAttendantSchema.PilotIdentifierList) && multiValuedProperty != null) { LocalizedException ex = ValidationHelper.ValidateDialedNumbers(this.DataObject.PilotIdentifierList, dialPlan); if (ex != null) { base.WriteError(ex, ErrorCategory.NotSpecified, this.DataObject); } foreach (string text in this.DataObject.PilotIdentifierList) { UMAutoAttendant umautoAttendant = UMAutoAttendant.FindAutoAttendantByPilotIdentifierAndDialPlan(text, this.DataObject.UMDialPlan); if (umautoAttendant != null && !umautoAttendant.Guid.Equals(this.DataObject.Guid)) { base.WriteError(new AutoAttendantExistsException(text, this.DataObject.UMDialPlan.Name), ErrorCategory.NotSpecified, null); } } if (dialPlan.URIType == UMUriType.SipName) { Utility.CheckForPilotIdentifierDuplicates(this.DataObject, this.ConfigurationSession, multiValuedProperty, new Task.TaskErrorLoggingDelegate(base.WriteError)); } } string timeZone = this.DataObject.TimeZone; if (this.DataObject.IsChanged(UMAutoAttendantSchema.BusinessHourFeatures)) { ValidationHelper.ValidateTimeZone(timeZone); } string property; try { property = UMAutoAttendantSchema.BusinessHoursKeyMapping.ToString(); MultiValuedProperty <CustomMenuKeyMapping> multiValuedProperty2 = this.DataObject.BusinessHoursKeyMapping; if (multiValuedProperty2 != null && multiValuedProperty2.Count > 0) { bool flag; ValidationHelper.ValidateCustomMenu(Strings.BusinessHoursSettings, this.ConfigurationSession, property, multiValuedProperty2, numberOfDigitsInExtension, this.DataObject, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), out flag); if (flag) { this.DataObject.BusinessHoursKeyMapping = multiValuedProperty2; } } property = UMAutoAttendantSchema.AfterHoursKeyMapping.ToString(); multiValuedProperty2 = this.DataObject.AfterHoursKeyMapping; if (multiValuedProperty2 != null && multiValuedProperty2.Count > 0) { bool flag2; ValidationHelper.ValidateCustomMenu(Strings.AfterHoursSettings, this.ConfigurationSession, property, multiValuedProperty2, numberOfDigitsInExtension, this.DataObject, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), out flag2); if (flag2) { this.DataObject.AfterHoursKeyMapping = multiValuedProperty2; } } } catch (LocalizedException exception) { base.WriteError(exception, ErrorCategory.NotSpecified, null); } bool speechEnabled = this.DataObject.SpeechEnabled; StatusEnum status = this.DataObject.Status; property = UMAutoAttendantSchema.DTMFFallbackAutoAttendant.ToString(); if (this.fallbackAA != null) { ValidationHelper.ValidateDtmfFallbackAA(this.DataObject, dialPlan, this.fallbackAA); } ADObjectId adobjectId = null; property = UMAutoAttendantSchema.AutomaticSpeechRecognitionEnabled.ToString(); if (this.DataObject.IsChanged(UMAutoAttendantSchema.AutomaticSpeechRecognitionEnabled) && speechEnabled && ValidationHelper.IsFallbackAAInDialPlan(this.ConfigurationSession, this.DataObject, out adobjectId)) { base.WriteError(new InvalidDtmfFallbackAutoAttendantException(Strings.InvalidSpeechEnabledAutoAttendant(adobjectId.ToString())), ErrorCategory.NotSpecified, null); } property = UMAutoAttendantSchema.Language.ToString(); if (this.DataObject.IsChanged(UMAutoAttendantSchema.Language)) { UMLanguage language = this.DataObject.Language; if (!Utility.IsUMLanguageAvailable(language)) { base.WriteError(new InvalidLanguageIdException(language.ToString()), ErrorCategory.NotSpecified, null); } } bool flag3 = this.IsBusinessHours(); if (!this.DataObject.NameLookupEnabled && !this.DataObject.CallSomeoneEnabled && ((flag3 && !this.DataObject.BusinessHoursTransferToOperatorEnabled && !this.DataObject.BusinessHoursKeyMappingEnabled) || (!flag3 && !this.DataObject.AfterHoursTransferToOperatorEnabled && !this.DataObject.AfterHoursKeyMappingEnabled))) { base.WriteError(new InvalidAutoAttendantException(Strings.InvalidMethodToDisableAA), ErrorCategory.NotSpecified, null); } LocalizedString empty = LocalizedString.Empty; if (!DialGroupEntry.ValidateGroup(dialPlan.ConfiguredInCountryOrRegionGroups, this.DataObject.AllowedInCountryOrRegionGroups, true, out empty)) { base.WriteError(new Exception(empty), ErrorCategory.WriteError, this.DataObject); } if (!DialGroupEntry.ValidateGroup(dialPlan.ConfiguredInternationalGroups, this.DataObject.AllowedInternationalGroups, false, out empty)) { base.WriteError(new Exception(empty), ErrorCategory.WriteError, this.DataObject); } if (this.DataObject.ForwardCallsToDefaultMailbox && string.IsNullOrEmpty(this.DataObject.DefaultMailboxLegacyDN)) { base.WriteError(new InvalidParameterException(Strings.DefaultMailboxRequiredWhenForwardTrue), ErrorCategory.NotSpecified, null); } if (this.DataObject.IsModified(UMAutoAttendantSchema.ContactScope) && this.DataObject.ContactScope == DialScopeEnum.DialPlan && dialPlan.SubscriberType == UMSubscriberType.Consumer) { base.WriteError(new InvalidParameterException(Strings.InvalidAutoAttendantScopeSetting), (ErrorCategory)1000, null); } } TaskLogger.LogExit(); }
public static LocalizedString GetFindDataObjectsInALVerboseString(IConfigDataProvider session, Type type, ADObjectId addressList) { return(Strings.VerboseTaskFindDataObjectsInAL(type.Name, addressList.ToString())); }