private void CheckDagMembership() { ADObjectId databaseAvailabilityGroup = this.m_server.DatabaseAvailabilityGroup; if (ADObjectId.IsNullOrEmpty(databaseAvailabilityGroup)) { base.WriteError(new AddDatabaseCopyNewCopyMustBeInDagException(this.m_server.Name, this.DataObject.Name), ErrorCategory.InvalidArgument, null); } DatabaseAvailabilityGroup databaseAvailabilityGroup2 = (DatabaseAvailabilityGroup)base.DataSession.Read <DatabaseAvailabilityGroup>(databaseAvailabilityGroup); if (databaseAvailabilityGroup2 == null) { base.WriteError(new AddDatabaseCopyNewCopyMustBeInDagException(this.m_server.Name, this.DataObject.Name), ErrorCategory.InvalidArgument, null); } if (ThirdPartyReplicationMode.Enabled == databaseAvailabilityGroup2.ThirdPartyReplication) { this.m_isThirdPartyReplicationEnabled = true; } ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession; foreach (DatabaseCopy databaseCopy in this.m_databaseCopies) { ADObjectId hostServer = databaseCopy.HostServer; MiniServer miniServer = topologyConfigurationSession.ReadMiniServer(hostServer, AddMailboxDatabaseCopy.s_miniServerProperties); ADObjectId databaseAvailabilityGroup3 = miniServer.DatabaseAvailabilityGroup; if (ADObjectId.IsNullOrEmpty(databaseAvailabilityGroup3)) { base.WriteError(new AddDatabaseCopyAllCopiesMustBeInTheDagException(this.DataObject.Name, this.m_server.Name, databaseAvailabilityGroup2.Name, miniServer.Name), ErrorCategory.InvalidArgument, null); } else if (!databaseAvailabilityGroup3.Equals(databaseAvailabilityGroup)) { base.WriteError(new AddDatabaseCopyAllCopiesMustBeInSameDagException(this.DataObject.Name, this.m_server.Name, databaseAvailabilityGroup2.Name, miniServer.Name, databaseAvailabilityGroup3.Name), ErrorCategory.InvalidArgument, null); } } }
private ExchangePrincipal CreateExchangePrincipal(IGenericADUser user, ADObjectId mdb, IMailboxLocation mailboxLocation, RemotingOptions remotingOptions, bool asArchive, Guid?aggregatedMailboxGuid, IDatabaseLocationProvider databaseLocationProvider, bool isContentIndexing = false) { ExchangePrincipalBuilder exchangePrincipalBuilder = ((remotingOptions & RemotingOptions.AllowHybridAccess) == RemotingOptions.AllowHybridAccess) ? new RemoteUserMailboxPrincipalBuilder(user) : this.GetExchangePrincipalBuilder(user); exchangePrincipalBuilder.SetRemotingOptions(remotingOptions); exchangePrincipalBuilder.SetDatabaseLocationProvider(databaseLocationProvider); if (!mdb.IsNullOrEmpty()) { exchangePrincipalBuilder.SetSelectedMailboxDatabase(mdb.ObjectGuid); } if (mailboxLocation != null) { exchangePrincipalBuilder.SetSelectedMailboxLocation(mailboxLocation); } if (asArchive) { exchangePrincipalBuilder.SelectArchiveMailbox(); } exchangePrincipalBuilder.BypassRecipientTypeValidation(isContentIndexing); if (aggregatedMailboxGuid != null && aggregatedMailboxGuid != Guid.Empty) { exchangePrincipalBuilder.SelectMailbox(aggregatedMailboxGuid.Value); } return(exchangePrincipalBuilder.Build()); }
protected override void ValidateRead(List <ValidationError> errors) { base.ValidateRead(errors); bool flag = ADObjectId.IsNullOrEmpty(this.RecipientRoot); switch (this.ScopeRestrictionType) { case ScopeRestrictionType.RecipientScope: break; case ScopeRestrictionType.ServerScope: case ScopeRestrictionType.PartnerDelegatedTenantScope: case ScopeRestrictionType.DatabaseScope: if (!flag) { errors.Add(new ObjectValidationError(DirectoryStrings.RootMustBeEmpty(this.ScopeRestrictionType), this.Identity, base.OriginatingServer)); } break; default: errors.Add(new ObjectValidationError(DirectoryStrings.UnKnownScopeRestrictionType(this.ScopeRestrictionType.ToString(), base.Name), this.Identity, base.OriginatingServer)); break; } if (string.IsNullOrEmpty(this.Filter)) { errors.Add(new ObjectValidationError(DirectoryStrings.FilterCannotBeEmpty(this.ScopeRestrictionType), this.Identity, base.OriginatingServer)); } if (this.Exclusive && this.ScopeRestrictionType == ScopeRestrictionType.PartnerDelegatedTenantScope) { errors.Add(new ObjectValidationError(DirectoryStrings.ScopeCannotBeExclusive(this.ScopeRestrictionType), this.Identity, base.OriginatingServer)); } }
// Token: 0x060006FC RID: 1788 RVA: 0x0001A384 File Offset: 0x00018584 internal static OrganizationId ResolveOrganizationId(ADObjectId objectId, ADObjectId rdnFromContainerToOrgContainer, ITenantConfigurationSession scSession) { if (scSession == null) { throw new ArgumentNullException("scSession"); } if (ADObjectId.IsNullOrEmpty(objectId) || string.IsNullOrEmpty(objectId.DistinguishedName)) { throw new ArgumentNullException("objectId"); } if (ADObjectId.IsNullOrEmpty(rdnFromContainerToOrgContainer) || string.IsNullOrEmpty(rdnFromContainerToOrgContainer.DistinguishedName)) { throw new ArgumentNullException("rdnFromContainerToOrgContainer"); } string text = objectId.DistinguishedName; string text2 = rdnFromContainerToOrgContainer.DistinguishedName + ","; while (text != null) { int num = text.IndexOf(text2, 0, StringComparison.OrdinalIgnoreCase); if (-1 == num) { break; } text = text.Substring(num + text2.Length); ExchangeConfigurationUnit exchangeConfigurationUnit = scSession.Read <ExchangeConfigurationUnit>(new ADObjectId(text)); if (exchangeConfigurationUnit != null) { return(exchangeConfigurationUnit.OrganizationId); } } return(OrganizationId.ForestWideOrgId); }
internal static DatabaseAvailabilityGroupConfiguration ReadDagConfig(ADObjectId dagConfigId, IConfigDataProvider configSession) { DatabaseAvailabilityGroupConfiguration result = null; if (!ADObjectId.IsNullOrEmpty(dagConfigId)) { result = (DatabaseAvailabilityGroupConfiguration)configSession.Read <DatabaseAvailabilityGroupConfiguration>(dagConfigId); } return(result); }
internal static StampGroup ReadStampGroup(ADObjectId stampGroupId, IConfigDataProvider configSession) { StampGroup result = null; if (!ADObjectId.IsNullOrEmpty(stampGroupId)) { result = (StampGroup)configSession.Read <StampGroup>(stampGroupId); } return(result); }
public static bool ResetPassword(ADObjectId adUserObjectId, SecureString newPassword, IRecipientSession recipientSession) { if (newPassword == null) { throw new ArgumentNullException("newPassword"); } if (adUserObjectId.IsNullOrEmpty()) { throw new ArgumentException("ADUser object ID cannot be null or empty", "adUserObjectId"); } recipientSession.SetPassword(adUserObjectId, newPassword); return(true); }
private IMailboxLocation BuildMailboxLocation(IDatabaseLocationProvider databaseLocationProvider, ADObjectId databaseId, RemotingOptions remotingOptions) { if (databaseId.IsNullOrEmpty()) { return(MailboxDatabaseLocation.Unknown); } Func <IMailboxLocation> func = () => new MailboxDatabaseLocation(databaseLocationProvider.GetLocationInfo(databaseId.ObjectGuid, false, (remotingOptions & RemotingOptions.AllowCrossSite) == RemotingOptions.AllowCrossSite)); if (this.useOnDemandLocation) { return(new OnDemandMailboxLocation(func)); } return(func()); }
public static ExDateTime GetPasswordExpirationDate(ADObjectId adUserObjectId, IRecipientSession recipientSession) { if (adUserObjectId.IsNullOrEmpty()) { throw new ArgumentException("ADUser object ID cannot be null or empty", "adUserObjectId"); } ADUser aduser = recipientSession.Read(adUserObjectId) as ADUser; if (aduser == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } if ((aduser.UserAccountControl & UserAccountControlFlags.DoNotExpirePassword) != UserAccountControlFlags.None) { return(ExDateTime.MaxValue); } ExDateTime?exDateTime = null; if (aduser.PasswordLastSet != null) { exDateTime = new ExDateTime?(new ExDateTime(ExTimeZone.UtcTimeZone, aduser.PasswordLastSet.Value)); } if (exDateTime == null) { return(ExDateTime.MaxValue); } IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAccountPartitionRootOrgScopeSet(adUserObjectId.GetPartitionId()), 86, "GetPasswordExpirationDate", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\DirectoryHelper.cs"); tenantOrTopologyConfigurationSession.UseConfigNC = false; ADDomain addomain = tenantOrTopologyConfigurationSession.Read <ADDomain>(aduser.Id.DomainId); if (addomain == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } EnhancedTimeSpan?maximumPasswordAge = addomain.MaximumPasswordAge; TimeSpan? timeSpan = (maximumPasswordAge != null) ? new TimeSpan?(maximumPasswordAge.GetValueOrDefault()) : null; if (timeSpan == null || timeSpan == TimeSpan.Zero) { return(ExDateTime.MaxValue); } return(exDateTime.Value.Add(timeSpan.Value)); }
internal bool IsFullyCoveredByOU(ADObjectId ouIdentity, out LocalizedString notTrueReason) { notTrueReason = LocalizedString.Empty; if (ouIdentity == null) { throw new ArgumentNullException("ouIdentity"); } if (string.IsNullOrEmpty(ouIdentity.DistinguishedName)) { throw new ArgumentNullException("ouIdentity.DistinguishedName"); } if (ADObjectId.IsNullOrEmpty(this.RecipientRoot)) { notTrueReason = DirectoryStrings.RootCannotBeEmpty(this.ScopeRestrictionType); ExTraceGlobals.AccessCheckTracer.TraceError(11001L, "IsFullyCoveredByOU: this instance has invalid empty Root."); return(false); } ExTraceGlobals.AccessCheckTracer.TraceFunction(11001L, "-->IsFullyCoveredByOU: this = (Id = {0}, Root = {1}, Type = {2}), OU = {3}", new object[] { base.Id, this.RecipientRoot, this.ScopeRestrictionType, ouIdentity.DistinguishedName }); bool flag = false; if (this.ScopeRestrictionType == ScopeRestrictionType.RecipientScope) { flag = this.RecipientRoot.IsDescendantOf(ouIdentity); if (!flag) { notTrueReason = DirectoryStrings.OUsNotSmallerOrEqual(this.RecipientRoot.ToString(), ouIdentity.ToString()); } } else { notTrueReason = DirectoryStrings.CannotCompareScopeObjectWithOU(base.Id.ToString(), this.ScopeRestrictionType.ToString(), ouIdentity.ToString()); } ExTraceGlobals.AccessCheckTracer.TraceFunction <bool>(11001L, "<--IsScopeSmallerOrEqualThan: return {0}", flag); return(flag); }
private IMailboxInfo BuildMailboxInfo(Guid mailboxGuid, ADObjectId mailboxDatabase, bool isSelected, ADObjectId selectedMailboxDatabase, IMailboxLocation selectedMailboxLocation, IGenericADUser adUser, IMailboxConfiguration configuration, Func <ADObjectId, IMailboxLocation> locationFactory) { ADObjectId adobjectId = mailboxDatabase; IMailboxLocation mailboxLocation = null; if (isSelected) { if (!selectedMailboxDatabase.IsNullOrEmpty()) { adobjectId = selectedMailboxDatabase; } mailboxLocation = selectedMailboxLocation; } try { return(new MailboxInfo(mailboxGuid, adobjectId, adUser, configuration, mailboxLocation ?? locationFactory(adobjectId))); } catch (ObjectNotFoundException) { } return(null); }
protected override void PrepareRecipientObject(ADGroup group) { TaskLogger.LogEnter(); base.PrepareRecipientObject(group); Organization organization; if (base.Organization == null) { organization = this.ConfigurationSession.GetOrgContainer(); } else { organization = this.ConfigurationSession.Read <ExchangeConfigurationUnit>(base.CurrentOrgContainerId); } ADObjectId adobjectId = null; base.TryGetExecutingUserId(out adobjectId); if (!this.IgnoreNamingPolicy.IsPresent && adobjectId != null) { ADUser user = (ADUser)RecipientTaskHelper.CreatePartitionOrRootOrgScopedGcSession(null, adobjectId).Read(adobjectId); string groupNameWithNamingPolicy = DistributionGroupTaskHelper.GetGroupNameWithNamingPolicy(organization, user, group, base.Name, ADObjectSchema.Name, new Task.ErrorLoggerDelegate(base.WriteError)); if (groupNameWithNamingPolicy.Length > 64) { base.WriteError(new RecipientTaskException(Strings.ErrorDistributionGroupNameTooLong), ExchangeErrorCategory.Client, null); } base.Name = groupNameWithNamingPolicy; if (!string.IsNullOrEmpty(base.DisplayName)) { base.DisplayName = DistributionGroupTaskHelper.GetGroupNameWithNamingPolicy(organization, user, group, base.DisplayName, ADRecipientSchema.DisplayName, new Task.ErrorLoggerDelegate(base.WriteError)); } } if (base.OrganizationalUnit == null && !ADObjectId.IsNullOrEmpty(organization.DistributionGroupDefaultOU)) { group.SetId(organization.DistributionGroupDefaultOU.GetChildId(base.Name)); } if (base.OrganizationalUnit == null && group[ADRecipientSchema.DefaultDistributionListOU] != null) { ADObjectId adobjectId2 = (ADObjectId)group[ADRecipientSchema.DefaultDistributionListOU]; RecipientTaskHelper.ResolveOrganizationalUnitInOrganization(new OrganizationalUnitIdParameter(adobjectId2), this.ConfigurationSession, base.CurrentOrganizationId, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ExchangeOrganizationalUnit>), ExchangeErrorCategory.Client, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError)); group.SetId(adobjectId2.GetChildId(base.Name)); } if (this.Type != GroupType.Distribution && this.Type != GroupType.Security) { base.WriteError(new RecipientTaskException(Strings.ErrorGroupTypeInvalid), ExchangeErrorCategory.Client, null); } if (base.Fields.IsModified(DistributionGroupSchema.ManagedBy)) { MailboxTaskHelper.StampOnManagedBy(this.DataObject, this.managedByRecipients, new Task.ErrorLoggerDelegate(base.WriteError)); } if (this.RoomList.IsPresent) { if (this.Type != GroupType.Distribution) { base.WriteError(new RecipientTaskException(Strings.ErrorCreateRoomListSecurityGroup(base.Name)), ExchangeErrorCategory.Client, base.Name); } group.RecipientTypeDetails = RecipientTypeDetails.RoomList; if (group.ManagedBy != null) { group.AcceptMessagesOnlyFromSendersOrMembers = new MultiValuedProperty <ADObjectId>(group.ManagedBy); } } MailboxTaskHelper.ValidateGroupManagedBy(base.TenantGlobalCatalogSession, group, this.managedByRecipients, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), new Task.ErrorLoggerDelegate(base.WriteError)); MailboxTaskHelper.ValidateGroupManagedByRecipientRestriction(base.TenantGlobalCatalogSession, group, this.managedByRecipients, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); group.GroupType = (GroupTypeFlags)((GroupType)8 | this.Type); if (!group.IsChanged(ADRecipientSchema.RecipientDisplayType)) { if ((group.GroupType & GroupTypeFlags.SecurityEnabled) == GroupTypeFlags.SecurityEnabled) { group.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.SecurityDistributionGroup); } else { group.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.DistributionGroup); } } if (string.IsNullOrEmpty(group.SamAccountName)) { IRecipientSession[] recipientSessions = new IRecipientSession[] { base.RootOrgGlobalCatalogSession }; if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId) { recipientSessions = new IRecipientSession[] { base.RootOrgGlobalCatalogSession, base.PartitionOrRootOrgGlobalCatalogSession }; } group.SamAccountName = RecipientTaskHelper.GenerateUniqueSamAccountName(recipientSessions, group.Id.DomainId, group.Name, true, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), false); } else { RecipientTaskHelper.IsSamAccountNameUnique(group, group.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); } if (string.IsNullOrEmpty(group.Alias)) { group.Alias = RecipientTaskHelper.GenerateUniqueAlias(base.TenantGlobalCatalogSession, base.CurrentOrganizationId, group.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (base.Fields.IsChanged(ADGroupSchema.Members) && this.Members != null) { foreach (RecipientIdParameter member in this.Members) { MailboxTaskHelper.ValidateAndAddMember(base.TenantGlobalCatalogSession, group, member, false, new Task.ErrorLoggerDelegate(base.WriteError), new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>)); } } if (this.CopyOwnerToMember.IsPresent && this.managedByRecipients != null) { foreach (ADRecipient adrecipient in this.managedByRecipients) { if (!group.Members.Contains(adrecipient.Id)) { MailboxTaskHelper.ValidateMemberInGroup(adrecipient, group, new Task.ErrorLoggerDelegate(base.WriteError)); group.Members.Add(adrecipient.Id); } } } if ((group.GroupType & GroupTypeFlags.Universal) == GroupTypeFlags.Universal) { MailboxTaskHelper.ValidateAddedMembers(base.TenantGlobalCatalogSession, group, new Task.ErrorLoggerDelegate(base.WriteError), new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>)); } if (!this.DataObject.IsModified(ADGroupSchema.MemberDepartRestriction)) { this.DataObject.MemberDepartRestriction = ((this.Type == GroupType.Security) ? MemberUpdateType.Closed : MemberUpdateType.Open); } if (group.ArbitrationMailbox == null) { group.ArbitrationMailbox = MailboxTaskHelper.GetArbitrationMailbox(base.TenantGlobalCatalogSession, base.CurrentOrgContainerId); if (group.ArbitrationMailbox == null) { if (group.MemberJoinRestriction == MemberUpdateType.ApprovalRequired || group.MemberDepartRestriction == MemberUpdateType.ApprovalRequired) { base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxNotSetForApproval(base.Name)), ExchangeErrorCategory.Client, group.Identity); } if (group.ModerationEnabled) { base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxNotSetForModeration(base.Name)), ExchangeErrorCategory.Client, group.Identity); } } } DistributionGroupTaskHelper.CheckMembershipRestriction(group, new Task.ErrorLoggerDelegate(base.WriteError)); TaskLogger.LogExit(); }
private bool IsArchiveMailUser(RecipientType recipientType, Guid archiveMailboxGuid, ADObjectId archiveDatabase) { return(recipientType == RecipientType.MailUser && archiveMailboxGuid != Guid.Empty && !archiveDatabase.IsNullOrEmpty()); }