private static string GetEasServerFromOrgRelationship(ADRecipient user, OrganizationRelationship organizationRelationship)
        {
            Uri targetOwaURL = organizationRelationship.TargetOwaURL;

            if (targetOwaURL != null && targetOwaURL.Host != null)
            {
                string text;
                if (targetOwaURL.Host.Contains(MobileRedirectOptimization.legacyO365OwaHost))
                {
                    text = MobileRedirectOptimization.correctO365OwaUrl;
                }
                else
                {
                    text = MobileRedirectOptimization.httpsPrefix + targetOwaURL.Host + MobileRedirectOptimization.activeSyncServerSuffix;
                }
                ExTraceGlobals.FrameworkTracer.TraceDebug <string, string>(0L, "[MobileRedirectOptimization] Redirect bypass succeeded, writing config xml for user {0} using EAS server name {1}.", MobileRedirectOptimization.SafeGetEmailAddressStringFromADUser(user), text);
                return(text);
            }
            ExTraceGlobals.FrameworkTracer.TraceError <string>(0L, "[MobileRedirectOptimization] TargetOwaUrl parsing failed for user {0}. Proceeding with <Redirect>.", MobileRedirectOptimization.SafeGetEmailAddressStringFromADUser(user));
            return(null);
        }
Exemple #2
0
 // Token: 0x060009E4 RID: 2532 RVA: 0x00041508 File Offset: 0x0003F708
 public void HandleEvent(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item)
 {
     if (ObjectType.MAPI_MESSAGE == mapiEvent.ItemType && item == null)
     {
         ExTraceGlobals.UserSettingsTracer.TraceDebug <string>((long)this.GetHashCode(), "Event is MAPI_MESSAGE but item is null, message class is {0}", mapiEvent.ObjectClass);
         return;
     }
     if (!itemStore.Capabilities.CanHaveUserConfigurationManager)
     {
         ExTraceGlobals.UserSettingsTracer.TraceDebug <string>((long)this.GetHashCode(), "Mailbox sesstion does not have UserConfigurationManager capability. Possibly an alternate mailbox, {0}.", itemStore.MailboxOwnerLegacyDN);
         return;
     }
     if (this.IsMailboxDeletedOrDisconnected(mapiEvent))
     {
         ExTraceGlobals.UserSettingsTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Processing Disabling event for mailbox {0} on database {1}", itemStore.MailboxOwnerLegacyDN, itemStore.MdbGuid);
         UserSettings  settings      = new UserSettings(itemStore);
         SystemMailbox systemMailbox = this.GetSystemMailbox();
         if (systemMailbox != null)
         {
             NotificationFactories.Instance.UpdateSettingUnderSystemMailbox(settings, systemMailbox);
         }
         SettingsChangeListener.Instance.RaiseSettingsChangedEvent(settings, new InfoFromUserMailboxSession(itemStore));
         return;
     }
     if (this.IsMailboxCreatedOrConnected(mapiEvent))
     {
         ExTraceGlobals.UserSettingsTracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Processing Enabling event for mailbox {0} on database {1}", itemStore.MailboxOwnerLegacyDN, itemStore.MdbGuid);
         using (VersionedXmlDataProvider versionedXmlDataProvider = new VersionedXmlDataProvider(itemStore))
         {
             TextMessagingAccount account = (TextMessagingAccount)versionedXmlDataProvider.Read <TextMessagingAccount>(itemStore.MailboxOwner.ObjectId);
             IRecipientSession    tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, itemStore.GetADSessionSettings(), 194, "HandleEvent", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\CalendarNotification\\SettingsChangeProcessor.cs");
             ADRecipient          adrecipient = tenantOrRootOrgRecipientSession.Read(itemStore.MailboxOwner.ObjectId);
             if (adrecipient != null)
             {
                 TextMessagingHelper.UpdateAndSaveTextMessgaingStateOnAdUser(account, adrecipient, tenantOrRootOrgRecipientSession);
             }
         }
     }
     this.HandleSettingsEvent(itemStore);
 }
Exemple #3
0
        protected override IConfigurable PrepareDataObject()
        {
            PartnerApplication partnerApplication = (PartnerApplication)base.PrepareDataObject();

            if (base.Fields.IsModified(PartnerApplicationSchema.AuthMetadataUrl))
            {
                if (partnerApplication.UseAuthServer)
                {
                    base.WriteError(new TaskException(Strings.ErrorPartnerApplicationUseAuthServerCannotSetUrl), ErrorCategory.InvalidArgument, null);
                }
                partnerApplication.AuthMetadataUrl = this.AuthMetadataUrl;
                OAuthTaskHelper.FetchAuthMetadata(partnerApplication, this.TrustAnySSLCertificate, false, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            else if (base.Fields.IsModified(PartnerApplicationSchema.Realm) || base.Fields.IsModified(PartnerApplicationSchema.ApplicationIdentifier) || base.Fields.IsModified(PartnerApplicationSchema.IssuerIdentifier))
            {
                base.WriteError(new TaskException(Strings.ErrorChangePartnerApplicationDirectTrust), ErrorCategory.InvalidArgument, null);
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.LinkedAccount))
            {
                if (this.LinkedAccount == null)
                {
                    partnerApplication.LinkedAccount = null;
                }
                else
                {
                    ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.LinkedAccount, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.LinkedAccount.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.LinkedAccount.ToString())));
                    partnerApplication.LinkedAccount = adrecipient.Id;
                }
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.AppOnlyPermissions))
            {
                partnerApplication.AppOnlyPermissions = this.AppOnlyPermissions;
            }
            if (base.Fields.IsModified(PartnerApplicationSchema.ActAsPermissions))
            {
                partnerApplication.ActAsPermissions = this.ActAsPermissions;
            }
            OAuthTaskHelper.ValidateApplicationRealmAndUniqueness(partnerApplication, this.ConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
            return(partnerApplication);
        }
Exemple #4
0
        private OrganizationId ResolveOrganization(ADObjectId entryId)
        {
            OrganizationId organizationId;

            try
            {
                if (entryId == null)
                {
                    throw new ArgumentNullException("entryId");
                }
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(entryId), 1191, "ResolveOrganization", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\MailboxSearch\\Common\\MailboxSearchConfigurationProvider.cs");
                ADRecipient       adrecipient = tenantOrRootOrgRecipientSession.Read(entryId);
                if (adrecipient == null)
                {
                    throw new ObjectNotFoundException(ServerStrings.ADUserNotFoundId(entryId));
                }
                organizationId = adrecipient.OrganizationId;
            }
            catch (InvalidOperationException arg)
            {
                Util.Tracer.TraceError <InvalidOperationException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg);
                throw;
            }
            catch (DataSourceOperationException arg2)
            {
                Util.Tracer.TraceError <DataSourceOperationException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg2);
                throw;
            }
            catch (TransientException arg3)
            {
                Util.Tracer.TraceError <TransientException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg3);
                throw;
            }
            catch (DataValidationException arg4)
            {
                Util.Tracer.TraceError <DataValidationException>((long)this.GetHashCode(), "ResolveUserOrganization error: {0}", arg4);
                throw;
            }
            return(organizationId);
        }
        protected void ApplyDelegationInternal(bool removeDelegation)
        {
            ADRecipient adrecipient = this.SecurityPrincipal.Sid.IsWellKnown(WellKnownSidType.SelfSid) ? this.DataObject : ((ADRecipient)this.SecurityPrincipal);

            if (adrecipient.RecipientType == RecipientType.UserMailbox)
            {
                ADUser dataObject = this.DataObject;
                ADUser aduser     = this.GetADUser(base.DataSession, dataObject);
                if (aduser != null)
                {
                    try
                    {
                        PermissionTaskHelper.SetDelegation(aduser, adrecipient, base.DataSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), removeDelegation);
                        if (!removeDelegation && ((ADUser)adrecipient).DelegateListBL.Count >= 16)
                        {
                            this.WriteWarning(Strings.WarningDelegatesExceededOutlookLimit);
                        }
                        return;
                    }
                    catch (DataValidationException exception)
                    {
                        base.WriteError(exception, ErrorCategory.WriteError, null);
                        return;
                    }
                    catch (DataSourceOperationException exception2)
                    {
                        base.WriteError(exception2, ErrorCategory.WriteError, null);
                        return;
                    }
                    catch (DataSourceTransientException exception3)
                    {
                        base.WriteError(exception3, ErrorCategory.WriteError, null);
                        return;
                    }
                }
                base.WriteVerbose(Strings.VerboseMailboxDelegateSkipNotADUser(this.DataObject.ToString()));
                return;
            }
            base.WriteVerbose(Strings.VerboseMailboxDelegateSkip(this.Instance.User.ToString()));
        }
 protected override void PrepareRecipientObject(TDataObject recipient)
 {
     TaskLogger.LogEnter();
     base.PrepareRecipientObject(recipient);
     if (base.Fields.Contains(ADRecipientSchema.ModeratedBy))
     {
         MultiValuedProperty <ModeratorIDParameter> multiValuedProperty = (MultiValuedProperty <ModeratorIDParameter>)base.Fields[ADRecipientSchema.ModeratedBy];
         int num = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled ? 10 : 25;
         if (multiValuedProperty != null && multiValuedProperty.Count > num)
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorTooManyModerators(num)), ExchangeErrorCategory.Client, null);
         }
         recipient.ModeratedBy = RecipientTaskHelper.GetModeratedByAdObjectIdFromParameterID(base.TenantGlobalCatalogSession, this.ModeratedBy, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), recipient, new Task.ErrorLoggerDelegate(base.WriteError));
     }
     if (base.Fields.IsModified(ADRecipientSchema.ArbitrationMailbox))
     {
         if (this.ArbitrationMailbox != null)
         {
             ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.ArbitrationMailbox, (IRecipientSession)base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.ArbitrationMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.ArbitrationMailbox.ToString())), ExchangeErrorCategory.Client);
             if (adrecipient.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox)
             {
                 base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMbxType(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, recipient.Identity);
             }
             if (MultiValuedPropertyBase.IsNullOrEmpty((ADMultiValuedProperty <ADObjectId>)adrecipient[ADUserSchema.ApprovalApplications]))
             {
                 base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMbxTypeForModerationAndAutogroup(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, recipient.Identity);
             }
             if (!recipient.OrganizationId.Equals(adrecipient.OrganizationId))
             {
                 base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxCrossOrg(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, recipient.Identity);
             }
             recipient.ArbitrationMailbox = adrecipient.Id;
         }
         else
         {
             recipient.ArbitrationMailbox = null;
         }
     }
     TaskLogger.LogExit();
 }
        protected override void ResolveLocalSecondaryIdentities()
        {
            base.ResolveLocalSecondaryIdentities();
            Organization organization = (Organization)this.GetDynamicParameters();

            if (base.Fields.IsModified(OrganizationSchema.MicrosoftExchangeRecipientReplyRecipient))
            {
                if (this.MicrosoftExchangeRecipientReplyRecipient != null)
                {
                    ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.MicrosoftExchangeRecipientReplyRecipient, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.MicrosoftExchangeRecipientReplyRecipient.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.MicrosoftExchangeRecipientReplyRecipient.ToString())));
                    organization.MicrosoftExchangeRecipientReplyRecipient = (ADObjectId)adrecipient.Identity;
                }
                else
                {
                    organization.MicrosoftExchangeRecipientReplyRecipient = null;
                }
            }
            if (base.Fields.IsModified(OrganizationSchema.HABRootDepartmentLink))
            {
                if (this.HierarchicalAddressBookRoot != null)
                {
                    ADRecipient adrecipient2 = (ADRecipient)base.GetDataObject <ADRecipient>(this.HierarchicalAddressBookRoot, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.HierarchicalAddressBookRoot.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.HierarchicalAddressBookRoot.ToString())));
                    organization.HierarchicalAddressBookRoot = (ADObjectId)adrecipient2.Identity;
                }
                else
                {
                    organization.HierarchicalAddressBookRoot = null;
                }
            }
            if (base.Fields.IsModified(OrganizationSchema.DistributionGroupDefaultOU))
            {
                if (this.DistributionGroupDefaultOU != null)
                {
                    ADOrganizationalUnit adorganizationalUnit = (ADOrganizationalUnit)base.GetDataObject <ADOrganizationalUnit>(this.DistributionGroupDefaultOU, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorOrganizationNotFound(this.DistributionGroupDefaultOU.ToString())), new LocalizedString?(Strings.ErrorOrganizationNotUnique(this.DistributionGroupDefaultOU.ToString())));
                    organization.DistributionGroupDefaultOU = (ADObjectId)adorganizationalUnit.Identity;
                    return;
                }
                organization.DistributionGroupDefaultOU = null;
            }
        }
Exemple #8
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADRecipient adrecipient = (ADRecipient)base.PrepareDataObject();

            if (!adrecipient.EmailAddressPolicyEnabled && adrecipient.PrimarySmtpAddress != adrecipient.OriginalPrimarySmtpAddress && adrecipient.WindowsEmailAddress == adrecipient.OriginalWindowsEmailAddress)
            {
                adrecipient.WindowsEmailAddress = adrecipient.PrimarySmtpAddress;
            }
            if (this.CreateDTMFMap)
            {
                adrecipient.PopulateDtmfMap(true);
            }
            if (base.Fields.IsModified(ADRecipientSchema.ArbitrationMailbox))
            {
                if (this.arbitrationMbx != null)
                {
                    if (!adrecipient.OrganizationId.Equals(this.arbitrationMbx.OrganizationId))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxCrossOrg(this.arbitrationMbx.Identity.ToString())), ExchangeErrorCategory.Client, adrecipient.Identity);
                    }
                    adrecipient.ArbitrationMailbox = this.arbitrationMbx.Id;
                }
                else
                {
                    adrecipient.ArbitrationMailbox = null;
                }
            }
            MultiValuedProperty <string> source;

            if (!this.isDeletingMailTipTranslations && this.isDeletingDefaultMailTip && adrecipient.TryGetOriginalValue <MultiValuedProperty <string> >(ADRecipientSchema.MailTipTranslations, out source))
            {
                if (source.Any((string translation) => !ADRecipient.IsDefaultTranslation(translation)))
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorMailTipRemoveDefaultAndTranslationsExist), ExchangeErrorCategory.Client, null);
                }
            }
            TaskLogger.LogExit();
            return(adrecipient);
        }
Exemple #9
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            this.DataObject = (ExchangeRoleAssignment)base.PrepareDataObject();
            if (base.HasErrors)
            {
                return(null);
            }
            ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.User, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorUserOrSecurityGroupNotFound(this.User.ToString())), new LocalizedString?(Strings.ErrorUserOrSecurityGroupNotUnique(this.User.ToString())));

            RoleHelper.ValidateRoleAssignmentUser(adrecipient, new Task.TaskErrorLoggingDelegate(base.WriteError), false);
            this.originalUserId              = this.DataObject.User;
            this.DataObject.User             = adrecipient.Id;
            this.DataObject.RoleAssigneeType = ExchangeRoleAssignment.RoleAssigneeTypeFromADRecipient(adrecipient);
            ((IDirectorySession)base.DataSession).LinkResolutionServer = adrecipient.OriginatingServer;
            if (!adrecipient.OrganizationId.Equals(OrganizationId.ForestWideOrgId) && !adrecipient.OrganizationId.Equals(this.DataObject.OrganizationId) && (OrganizationId.ForestWideOrgId.Equals(this.DataObject.OrganizationId) || !this.DataObject.OrganizationId.OrganizationalUnit.IsDescendantOf(adrecipient.OrganizationId.OrganizationalUnit)))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorOrgUserBeAssignedToParentOrg(this.User.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Id);
            }
            TaskLogger.LogExit();
            return(this.DataObject);
        }
Exemple #10
0
        internal static string GetSipUri(string emailAddress, IUserContext userContext)
        {
            IRecipientSession recipientSession = InstantMessageUtilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.IgnoreInvalid, true, userContext.ExchangePrincipal, false, userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN);

            try
            {
                SmtpProxyAddress proxyAddress = new SmtpProxyAddress(emailAddress, true);
                ADRecipient      adrecipient  = recipientSession.FindByProxyAddress(proxyAddress);
                if (adrecipient != null)
                {
                    string sipUri = ADPersonToContactConverter.GetSipUri(adrecipient);
                    Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.InstantMessagingTracer.TraceDebug <string, string>(0L, "SIPUri for {0}: {1}", emailAddress, sipUri);
                    return(sipUri);
                }
            }
            catch (NonUniqueRecipientException ex)
            {
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.InstantMessagingTracer.TraceError <string>(0L, "Failed to get unique recipient: Error: {0}", ex.Message);
            }
            Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.InstantMessagingTracer.TraceError <string>(0L, "Failed to get SIP Address for: {0}", emailAddress);
            return(null);
        }
Exemple #11
0
        private SharingSubscriptionData CreateSubscriptionData(ADRecipient mailboxOwner, SharingContext context, SharedFolderData sharedFolderData)
        {
            SharedFolderDataRecipient matchingRecipient = this.GetMatchingRecipient(sharedFolderData, mailboxOwner);

            if (sharedFolderData.FederationUri == null)
            {
                throw new InvalidSharingDataException("FederationUri", string.Empty);
            }
            if (!Uri.IsWellFormedUriString(sharedFolderData.FederationUri, UriKind.Absolute))
            {
                throw new InvalidSharingDataException("FederationUri", sharedFolderData.FederationUri);
            }
            if (sharedFolderData.SharingUrl == null)
            {
                throw new InvalidSharingDataException("SharingUrl", string.Empty);
            }
            if (!Uri.IsWellFormedUriString(sharedFolderData.SharingUrl, UriKind.Absolute))
            {
                throw new InvalidSharingDataException("SharingUrl", sharedFolderData.SharingUrl);
            }
            return(new SharingSubscriptionData(sharedFolderData.DataType, context.InitiatorSmtpAddress, context.InitiatorName, sharedFolderData.FolderId, context.FolderName, context.IsPrimary, new Uri(sharedFolderData.FederationUri), new Uri(sharedFolderData.SharingUrl), null, matchingRecipient.SharingKey, matchingRecipient.SmtpAddress));
        }
        private static void AddContactProperties(UserContext userContext, Contact contact, ADRecipient adRecipient, Participant participant)
        {
            IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext);

            contact.JobTitle       = (string)adRecipient[ADOrgPersonSchema.Title];
            contact.Company        = (string)adRecipient[ADOrgPersonSchema.Company];
            contact.Department     = (string)adRecipient[ADOrgPersonSchema.Department];
            contact.OfficeLocation = (string)adRecipient[ADOrgPersonSchema.Office];
            if (adRecipient[ADOrgPersonSchema.Manager] != null)
            {
                ADRecipient adrecipient = recipientSession.Read((ADObjectId)adRecipient[ADOrgPersonSchema.Manager]);
                if (adrecipient != null && !string.IsNullOrEmpty(adrecipient.DisplayName))
                {
                    contact[ContactSchema.Manager] = adrecipient.DisplayName;
                }
            }
            contact[ContactSchema.AssistantName] = (string)adRecipient[ADRecipientSchema.AssistantName];
            contact.DisplayName = (string)adRecipient[ADRecipientSchema.DisplayName];
            contact[ContactSchema.GivenName]                 = (string)adRecipient[ADOrgPersonSchema.FirstName];
            contact[ContactSchema.Surname]                   = (string)adRecipient[ADOrgPersonSchema.LastName];
            contact[ContactSchema.YomiFirstName]             = (string)adRecipient[ADRecipientSchema.PhoneticFirstName];
            contact[ContactSchema.YomiLastName]              = (string)adRecipient[ADRecipientSchema.PhoneticLastName];
            contact[ContactSchema.YomiCompany]               = (string)adRecipient[ADRecipientSchema.PhoneticCompany];
            contact[ContactSchema.FileAsId]                  = ContactUtilities.GetDefaultFileAs();
            contact.EmailAddresses[EmailAddressIndex.Email1] = participant;
            contact[ContactSchema.PrimaryTelephoneNumber]    = (string)adRecipient[ADOrgPersonSchema.Phone];
            contact[ContactSchema.BusinessPhoneNumber]       = (string)adRecipient[ADOrgPersonSchema.Phone];
            contact[ContactSchema.HomePhone]                 = (string)adRecipient[ADOrgPersonSchema.HomePhone];
            contact[ContactSchema.HomePhone2]                = DirectoryAssistance.GetFirstResource((MultiValuedProperty <string>)adRecipient[ADOrgPersonSchema.OtherHomePhone]);
            contact[ContactSchema.WorkFax]                   = (string)adRecipient[ADOrgPersonSchema.Fax];
            contact[ContactSchema.OtherFax]                  = DirectoryAssistance.GetFirstResource((MultiValuedProperty <string>)adRecipient[ADOrgPersonSchema.OtherFax]);
            contact[ContactSchema.Pager]                 = (string)adRecipient[ADOrgPersonSchema.Pager];
            contact[ContactSchema.MobilePhone]           = (string)adRecipient[ADOrgPersonSchema.MobilePhone];
            contact[ContactSchema.WorkAddressStreet]     = (string)adRecipient[ADOrgPersonSchema.StreetAddress];
            contact[ContactSchema.WorkAddressState]      = (string)adRecipient[ADOrgPersonSchema.StateOrProvince];
            contact[ContactSchema.WorkAddressPostalCode] = (string)adRecipient[ADOrgPersonSchema.PostalCode];
            contact[ContactSchema.WorkAddressCity]       = (string)adRecipient[ADOrgPersonSchema.City];
            contact[ContactSchema.WorkAddressCountry]    = (string)adRecipient[ADOrgPersonSchema.Co];
        }
        protected override FindMembersInUnifiedGroupResponse InternalExecute()
        {
            FindMembersInUnifiedGroupResponse findMembersInUnifiedGroupResponse = new FindMembersInUnifiedGroupResponse();
            ADRecipient adrecipient = base.CallContext.ADRecipientSessionContext.GetADRecipientSession().FindByProxyAddress(this.request.ProxyAddress);
            ADUser      aduser      = adrecipient as ADUser;

            if (adrecipient == null)
            {
                throw new InvalidCastException("Expected a recipient of ADUser type");
            }
            UnifiedGroupADAccessLayer unifiedGroupADAccessLayer = new UnifiedGroupADAccessLayer(aduser, aduser.OriginatingServer);

            if (this.request.Filter != null)
            {
                IEnumerable <UnifiedGroupParticipant> membersByAnrMatch = unifiedGroupADAccessLayer.GetMembersByAnrMatch(this.request.Filter.Trim().ToLower(), true, 101);
                ModernGroupMemberType[] array = this.ConvertListToMemberTypeArray(membersByAnrMatch);
                findMembersInUnifiedGroupResponse.HasMoreMembers = (array.Length > 100);
                Array.Resize <ModernGroupMemberType>(ref array, Math.Min(array.Length, 100));
                findMembersInUnifiedGroupResponse.Members = array;
            }
            return(findMembersInUnifiedGroupResponse);
        }
Exemple #14
0
        internal static MultiValuedProperty <ADObjectId> ConvertTo(IRecipientSession recipientSession, MultiValuedProperty <MailboxIdParameter> mailboxIds, DataAccessHelper.GetDataObjectDelegate getDataObject, Task.TaskErrorLoggingDelegate writeError)
        {
            if (mailboxIds == null)
            {
                return(null);
            }
            MultiValuedProperty <ADObjectId> multiValuedProperty = new MultiValuedProperty <ADObjectId>();

            foreach (MailboxIdParameter mailboxIdParameter in mailboxIds)
            {
                ADRecipient adrecipient = (ADRecipient)getDataObject(mailboxIdParameter, recipientSession, null, null, new LocalizedString?(Strings.ExceptionUserObjectNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorSearchUserNotUnique(mailboxIdParameter.ToString())));
                if (Array.IndexOf <RecipientTypeDetails>(MailboxAuditLogSearch.SupportedRecipientTypes, adrecipient.RecipientTypeDetails) == -1)
                {
                    writeError(new ArgumentException(Strings.ErrorInvalidRecipientType(adrecipient.ToString(), adrecipient.RecipientTypeDetails.ToString())), ErrorCategory.InvalidArgument, null);
                }
                if (!multiValuedProperty.Contains(adrecipient.Id))
                {
                    multiValuedProperty.Add(adrecipient.Id);
                }
            }
            return(multiValuedProperty);
        }
Exemple #15
0
        internal static MultiValuedProperty <ADRecipient> ResolveAndSeparateMessageDeliveryRestrictionRecipientIdentities(MultiValuedProperty <DeliveryRecipientIdParameter> identities, string parameterName, IRecipientSession recipientSession, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.ErrorLoggerDelegate writeError, out MultiValuedProperty <ADObjectId> resolvedGroups, out MultiValuedProperty <ADObjectId> resolvedIndividuals)
        {
            resolvedGroups      = null;
            resolvedIndividuals = null;
            MultiValuedProperty <ADRecipient> multiValuedProperty = new MultiValuedProperty <ADRecipient>();

            foreach (RecipientIdParameter recipientIdParameter in identities)
            {
                ADRecipient adrecipient = (ADRecipient)getDataObject(recipientIdParameter, recipientSession, null, null, new LocalizedString?(Strings.ErrorRecipientNotFound(recipientIdParameter.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(recipientIdParameter.ToString())), ExchangeErrorCategory.Client);
                multiValuedProperty.Add(adrecipient);
                if ((resolvedGroups != null && resolvedGroups.Contains(adrecipient.Id)) || (resolvedIndividuals != null && resolvedIndividuals.Contains(adrecipient.Id)))
                {
                    writeError(new RecipientTaskException(Strings.ErrorRecipientIdParamElementsNotUnique(parameterName, adrecipient.Id.ToString())), ExchangeErrorCategory.Client, recipientIdParameter);
                }
                bool flag  = ADRecipient.IsAllowedDeliveryRestrictionGroup(adrecipient.RecipientType);
                bool flag2 = ADRecipient.IsAllowedDeliveryRestrictionIndividual(adrecipient.RecipientType);
                if (!flag && !flag2)
                {
                    writeError(new RecipientTaskException(Strings.ErrorGroupOrIndividualRecipientNeeded(recipientIdParameter.ToString())), ExchangeErrorCategory.Client, recipientIdParameter);
                }
                if (flag)
                {
                    if (resolvedGroups == null)
                    {
                        resolvedGroups = new MultiValuedProperty <ADObjectId>();
                    }
                    resolvedGroups.Add(adrecipient.Id);
                }
                else
                {
                    if (resolvedIndividuals == null)
                    {
                        resolvedIndividuals = new MultiValuedProperty <ADObjectId>();
                    }
                    resolvedIndividuals.Add(adrecipient.Id);
                }
            }
            return(multiValuedProperty);
        }
        // Token: 0x0600313D RID: 12605 RVA: 0x00122B08 File Offset: 0x00120D08
        private static string GetContactNameFromLegacyDN(string legacyDN, UserContext userContext)
        {
            if (legacyDN == null)
            {
                throw new ArgumentNullException("legacyDN");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            AdRecipientBatchQuery adRecipientBatchQuery = new AdRecipientBatchQuery(userContext, new string[]
            {
                legacyDN
            });
            ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(legacyDN);

            if (adRecipient == null || string.IsNullOrEmpty(adRecipient.DisplayName))
            {
                return(LocalizedStrings.GetNonEncoded(-1626952556));
            }
            return(adRecipient.DisplayName);
        }
        private IEnumerable <UserObject> ExtractAttendees(IAttendeeCollection attendeeCollection, Participant organizerParticipant, bool dlParticipantsOnly)
        {
            Dictionary <ADObjectId, UserObject> dictionary = new Dictionary <ADObjectId, UserObject>(attendeeCollection.Count);
            HashSet <ADObjectId> hashSet = new HashSet <ADObjectId>();
            Dictionary <ProxyAddress, UserObject> dictionary2 = new Dictionary <ProxyAddress, UserObject>();
            int expandedDLCount = 0;

            foreach (Attendee attendee in attendeeCollection)
            {
                if (CalendarValidator.IsValidParticipant(attendee.Participant))
                {
                    ProxyAddress      attendeeProxyAddress = ProxyAddress.Parse(attendee.Participant.RoutingType, attendee.Participant.EmailAddress);
                    ADRecipient       attendeeRecipient    = null;
                    ADOperationResult adoperationResult    = ADNotificationAdapter.TryRunADOperation(delegate()
                    {
                        attendeeRecipient = this.recipientSession.FindByProxyAddress(attendeeProxyAddress);
                    });
                    if (!adoperationResult.Succeeded || attendeeRecipient == null)
                    {
                        this.ExtractUnaccessibleAttendee(organizerParticipant, dictionary2, attendee, attendeeProxyAddress);
                    }
                    else if (hashSet.Contains(attendeeRecipient.Id))
                    {
                        AttendeeExtractor.RevisitAttendee(dictionary, attendee, attendeeRecipient);
                    }
                    else if (attendeeRecipient is ADGroup)
                    {
                        AttendeeExtractor.DLExpansionHandler dlexpansionHandler = new AttendeeExtractor.DLExpansionHandler(organizerParticipant, dictionary, hashSet, expandedDLCount, attendee, attendeeRecipient, this.recipientSession, this.expansionManager);
                        expandedDLCount = dlexpansionHandler.ExpandDL();
                    }
                    else if (!dlParticipantsOnly)
                    {
                        hashSet.Add(attendeeRecipient.Id);
                        AttendeeExtractor.DLExpansionHandler.AddOrganizerFilteredAttendee <ADObjectId>(dictionary, attendeeRecipient.Id, new UserObject(attendee, attendeeRecipient, this.recipientSession), organizerParticipant, this.recipientSession);
                    }
                }
            }
            return(dictionary.Values.Concat(dictionary2.Values));
        }
        public List <SecurityIdentifier> ConvertGuidsToSid(string[] rawGuids)
        {
            List <Guid> list = new List <Guid>();

            foreach (string input in rawGuids)
            {
                Guid guid;
                if (!Guid.TryParse(input, out guid))
                {
                    throw new FaultException(string.Format("Guid {0} is invalid", guid));
                }
                list.Add(guid);
            }
            if (list != null && list.Any <Guid>())
            {
                IRecipientSession         session = (IRecipientSession)this.CreateAdSession();
                List <SecurityIdentifier> list2   = new List <SecurityIdentifier>();
                foreach (Guid guid2 in list)
                {
                    SecurityPrincipalIdParameter securityPrincipalIdParameter = new SecurityPrincipalIdParameter(guid2.ToString());
                    IEnumerable <ADRecipient>    objects = securityPrincipalIdParameter.GetObjects <ADRecipient>(null, session);
                    using (IEnumerator <ADRecipient> enumerator2 = objects.GetEnumerator())
                    {
                        if (enumerator2.MoveNext())
                        {
                            ADRecipient adrecipient = enumerator2.Current;
                            list2.Add(adrecipient.MasterAccountSid ?? ((IADSecurityPrincipal)adrecipient).Sid);
                            if (enumerator2.MoveNext())
                            {
                                throw new Exception(Strings.ErrorUserNotUnique(guid2.ToString()));
                            }
                        }
                    }
                }
                return(list2);
            }
            return(new List <SecurityIdentifier>());
        }
        // Token: 0x06000F32 RID: 3890 RVA: 0x0005AC20 File Offset: 0x00058E20
        private bool IsFlightingEnabled(out string reason)
        {
            reason = null;
            ADRecipient adrecipient = DirectoryHelper.ReadADRecipient(this.publicFolderSession.MailboxOwner.MailboxInfo.MailboxGuid, this.publicFolderSession.MailboxOwner.MailboxInfo.IsArchive, this.publicFolderSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));

            if (adrecipient == null)
            {
                reason = string.Format("ReadADRecipient returned null. MailboxOwner: {0} Organization: {1} LegacyExchangeDN: {2}", this.publicFolderSession.MailboxOwner.ToString(), this.publicFolderSession.MailboxOwner.MailboxInfo.OrganizationId.ToString(), this.publicFolderSession.MailboxOwner.LegacyDn);
                return(false);
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                reason = string.Format("Failed to cast ADRecipient to ADUser. MailboxOwner: {0} Organization: {1} LegacyExchangeDN: {2} OU: {3}", new object[]
                {
                    this.publicFolderSession.MailboxOwner.ToString(),
                    this.publicFolderSession.MailboxOwner.MailboxInfo.OrganizationId.ToString(),
                    adrecipient.LegacyExchangeDN,
                    adrecipient.OU
                });
                return(false);
            }
            VariantConfigurationSnapshot snapshot = VariantConfiguration.GetSnapshot(aduser.GetContext(null), null, null);
            bool enabled = snapshot.MailboxAssistants.PublicFolderSplit.Enabled;

            if (!enabled)
            {
                reason = string.Format("ADUser not flighted, as per the VariantConfigurationSnapshot. MailboxOwner: {0} Organization: {1} LegacyExchangeDN: {2} OU: {3}", new object[]
                {
                    this.publicFolderSession.MailboxOwner.ToString(),
                    this.publicFolderSession.MailboxOwner.MailboxInfo.OrganizationId.ToString(),
                    aduser.LegacyExchangeDN,
                    aduser.OU
                });
            }
            return(enabled);
        }
Exemple #20
0
        // Token: 0x0600114C RID: 4428 RVA: 0x00047B28 File Offset: 0x00045D28
        private void ComputeTargetADObjectIdAndStampOntoRequest(PhotoRequest request)
        {
            if (request.TargetAdObjectId != null)
            {
                return;
            }
            if (request.TargetPrincipal != null && request.TargetPrincipal.ObjectId != null)
            {
                request.TargetAdObjectId = request.TargetPrincipal.ObjectId;
                return;
            }
            if (string.IsNullOrEmpty(request.TargetSmtpAddress) || !SmtpAddress.IsValidSmtpAddress(request.TargetSmtpAddress))
            {
                return;
            }
            ADRecipient adrecipient = this.recipientSession.FindByProxyAddress(ProxyAddress.Parse(request.TargetSmtpAddress));

            if (adrecipient == null)
            {
                return;
            }
            request.TargetAdObjectId = adrecipient.Id;
        }
Exemple #21
0
        protected override bool ShouldSkipObject(IConfigurable dataObject)
        {
            if (dataObject is PagedPositionInfo)
            {
                return(false);
            }
            RecipientType        recipientType;
            RecipientTypeDetails recipientTypeDetails;

            if (dataObject is ReducedRecipient)
            {
                ReducedRecipient reducedRecipient = dataObject as ReducedRecipient;
                recipientType        = reducedRecipient.RecipientType;
                recipientTypeDetails = reducedRecipient.RecipientTypeDetails;
            }
            else
            {
                ADRecipient adrecipient = dataObject as ADRecipient;
                recipientType        = adrecipient.RecipientType;
                recipientTypeDetails = adrecipient.RecipientTypeDetails;
            }
            return(Array.IndexOf <RecipientType>(this.RecipientTypes, recipientType) == -1 || (this.InternalRecipientTypeDetails != null && this.InternalRecipientTypeDetails.Length > 0 && Array.IndexOf <RecipientTypeDetails>(this.InternalRecipientTypeDetails, recipientTypeDetails) == -1));
        }
Exemple #22
0
        private bool IsUsersEmailOrDomain(string email, bool isDomain)
        {
            ADRecipient adrecipient = this.Session.Read(base.MailboxSession.MailboxOwner.ObjectId);

            if (adrecipient == null)
            {
                return(false);
            }
            foreach (ProxyAddress proxyAddress in adrecipient.EmailAddresses)
            {
                if (proxyAddress != null && proxyAddress.Prefix == ProxyAddressPrefix.Smtp && SmtpAddress.IsValidSmtpAddress(proxyAddress.AddressString))
                {
                    SmtpAddress smtpAddress = (SmtpAddress)((SmtpProxyAddress)proxyAddress);
                    string      b           = isDomain ? smtpAddress.Domain.ToString() : smtpAddress.ToString();
                    string      a           = isDomain ? email.Substring(1) : email;
                    if (string.Equals(a, b, StringComparison.OrdinalIgnoreCase))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #23
0
        // Token: 0x06000935 RID: 2357 RVA: 0x000367A0 File Offset: 0x000349A0
        public ADABContact(ABSession ownerSession, ADRecipient recipient) : base(ownerSession)
        {
            if (recipient == null)
            {
                throw new ArgumentNullException("recipient");
            }
            if (recipient.Id == null)
            {
                throw new ArgumentException("recipient.Id can't be null.", "recipient.Id");
            }
            switch (recipient.RecipientType)
            {
            case RecipientType.MailUniversalDistributionGroup:
            case RecipientType.MailUniversalSecurityGroup:
            case RecipientType.MailNonUniversalGroup:
            case RecipientType.DynamicDistributionGroup:
                throw new ArgumentException("RecipientType " + recipient.RecipientType.ToString() + " shouldn't be wrapped in an ADABContact.", "recipient");

            default:
                this.recipient = recipient;
                return;
            }
        }
Exemple #24
0
 // Token: 0x060003E0 RID: 992 RVA: 0x0000E8BC File Offset: 0x0000CABC
 private static void SanitizeMailTips(ADRecipient recipient)
 {
     if (recipient.MailTipTranslations != null)
     {
         bool isReadOnly = recipient.IsReadOnly;
         if (isReadOnly)
         {
             recipient.SetIsReadOnly(false);
         }
         for (int i = 0; i < recipient.MailTipTranslations.Count; i++)
         {
             string str;
             string text;
             if (ADRecipient.TryGetMailTipParts(recipient.MailTipTranslations[i], out str, out text) && !string.IsNullOrEmpty(text))
             {
                 using (StringReader stringReader = new StringReader(text))
                 {
                     using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
                     {
                         HtmlToHtml htmlToHtml = new HtmlToHtml();
                         htmlToHtml.SetPreserveDisplayNoneStyle(true);
                         htmlToHtml.InputEncoding  = Encoding.UTF8;
                         htmlToHtml.OutputEncoding = Encoding.UTF8;
                         htmlToHtml.FilterHtml     = true;
                         htmlToHtml.Convert(stringReader, stringWriter);
                         string str2 = stringWriter.ToString();
                         recipient.MailTipTranslations[i] = str + ":" + str2;
                     }
                 }
             }
         }
         if (isReadOnly)
         {
             recipient.SetIsReadOnly(true);
         }
     }
 }
 private static void PrePopulateUserGroupSids(SidBasedIdentity sidBasedIdentity)
 {
     if (sidBasedIdentity.PrepopulatedGroupSidIds == null || sidBasedIdentity.PrepopulatedGroupSidIds.Count <string>() <= 0)
     {
         ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "Attempting to prepopulate group SIDS for user '{0}'.", sidBasedIdentity.Sid.Value);
         if (sidBasedIdentity.UserOrganizationId != null)
         {
             List <string>     list = null;
             IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(sidBasedIdentity.UserOrganizationId), 647, "PrePopulateUserGroupSids", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\common\\OwaClientSecurityContextIdentity.cs");
             if (tenantOrRootOrgRecipientSession != null)
             {
                 ExTraceGlobals.CoreCallTracer.TraceDebug <string>(0L, "OwaClientSecurityContextIdentity.GetUserGroupSidIds created IRecipientSession instance for user '{0}'.", sidBasedIdentity.Sid.Value);
                 ADRecipient adrecipient = tenantOrRootOrgRecipientSession.FindBySid(sidBasedIdentity.Sid);
                 if (adrecipient != null)
                 {
                     ExTraceGlobals.CoreCallTracer.TraceDebug <string, SmtpAddress, string>(0L, "OwaClientSecurityContextIdentity.GetUserGroupSidIds fetched ADRecipient instance with DisplaName '{0}' and PrimarySmtpAddress '{1}' for user '{2}'.", adrecipient.DisplayName, adrecipient.PrimarySmtpAddress, sidBasedIdentity.Sid.Value);
                     list = tenantOrRootOrgRecipientSession.GetTokenSids(adrecipient, AssignmentMethod.S4U);
                 }
                 else
                 {
                     ExTraceGlobals.CoreCallTracer.TraceError <string>(0L, "OwaClientSecurityContextIdentity.GetUserGroupSidIds was unable to get ADRecipient instance for user '{0}'.", sidBasedIdentity.Sid.Value);
                 }
             }
             else
             {
                 ExTraceGlobals.CoreCallTracer.TraceError <string>(0L, "OwaClientSecurityContextIdentity.GetUserGroupSidIds was unable to get IRecipientSession instance for user '{0}'.", sidBasedIdentity.Sid.Value);
             }
             if (list == null)
             {
                 ExTraceGlobals.CoreCallTracer.TraceError <string>(0L, "OwaClientSecurityContextIdentity.GetUserGroupSidIds was unable to find any group SIDs for user '{0}'.", sidBasedIdentity.Sid.Value);
                 return;
             }
             ExTraceGlobals.CoreCallTracer.TraceDebug <string, string>(0L, "Prepopulating User group SIds '{0}', for user '{1}'.", string.Join(", ", list), sidBasedIdentity.Sid.Value);
             sidBasedIdentity.PrepopulateGroupSidIds(list);
         }
     }
 }
Exemple #26
0
        internal Permission AddEntry(PermissionSecurityPrincipal securityPrincipal, MemberRights memberRights)
        {
            this.CheckValid();
            EnumValidator.ThrowIfInvalid <MemberRights>(memberRights, "memberRights");
            if (securityPrincipal == null)
            {
                throw new ArgumentNullException("securityPrincipal");
            }
            if (string.IsNullOrEmpty(securityPrincipal.IndexString))
            {
                throw new ArgumentException("SecurityPrincipal must at least have a valid index string.", "securityPrincipal");
            }
            if (securityPrincipal.Type == PermissionSecurityPrincipal.SecurityPrincipalType.ADRecipientPrincipal && !PermissionTable.isCrossPremiseDelegateAllowedForMailboxOwner)
            {
                ADRecipient adrecipient = securityPrincipal.ADRecipient;
                if (!ADRecipient.IsValidRecipient(adrecipient, !this.isPublicFolder))
                {
                    throw new ArgumentException("Cannot use " + adrecipient.DisplayName + " as security principal", "securityPrincipal");
                }
            }
            Permission permission = null;

            if (!this.permissions.ContainsKey(securityPrincipal.IndexString))
            {
                if (this.removedPermissions.TryGetValue(securityPrincipal.IndexString, out permission))
                {
                    this.removedPermissions.Remove(securityPrincipal.IndexString);
                    permission.MemberRights = memberRights;
                }
                else
                {
                    permission = this.PermissionSet.CreatePermission(securityPrincipal, memberRights);
                }
            }
            this.AddPermissionEntry(securityPrincipal, permission);
            return(permission);
        }
Exemple #27
0
        // Token: 0x06001AB6 RID: 6838 RVA: 0x00064D7C File Offset: 0x00062F7C
        private List <BodyContentAttributedValue> GetNotesFromActiveDirectory(ADObjectId adObjectId)
        {
            PersonId personId = this.IsAdPersonLinkedInMailbox(adObjectId);

            if (personId != null)
            {
                return(this.GetNotesFromStore(personId));
            }
            ADRecipient adrecipient = this.adRecipientSession.FindByObjectGuid(adObjectId.ObjectGuid);
            List <BodyContentAttributedValue> list = new List <BodyContentAttributedValue>();

            if (adrecipient != null)
            {
                IADOrgPerson iadorgPerson = adrecipient as IADOrgPerson;
                if (iadorgPerson != null && !string.IsNullOrWhiteSpace(iadorgPerson.Notes))
                {
                    BodyContentType bodyContentType = new BodyContentType();
                    bodyContentType.BodyType = BodyType.Text;
                    if (iadorgPerson.Notes.Length > this.maxBytesToFetch)
                    {
                        bodyContentType.Value       = iadorgPerson.Notes.Substring(0, this.maxBytesToFetch);
                        bodyContentType.IsTruncated = true;
                    }
                    else
                    {
                        bodyContentType.Value       = iadorgPerson.Notes;
                        bodyContentType.IsTruncated = false;
                    }
                    BodyContentAttributedValue item = new BodyContentAttributedValue(bodyContentType, new string[]
                    {
                        WellKnownNetworkNames.GAL
                    });
                    list.Add(item);
                }
            }
            return(list);
        }
Exemple #28
0
        private void AddADRecipientSupervisionListEntry(bool isGroup, ADRecipient adRecipientToAdd)
        {
            MultiValuedProperty <ADObjectIdWithString> supervisionListForADRecipient = base.GetSupervisionListForADRecipient(isGroup);
            ADObjectIdWithString adobjectIdWithString = null;

            string[] array = null;
            PropertyValidationError propertyValidationError = base.FindADRecipientEntry(adRecipientToAdd, supervisionListForADRecipient, out adobjectIdWithString, out array);

            if (propertyValidationError != null)
            {
                return;
            }
            if (adobjectIdWithString != null)
            {
                foreach (string text in array)
                {
                    if (text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryAlreadyPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
                    }
                }
                string stringValue        = this.Tag.ToLower() + "," + adobjectIdWithString.StringValue;
                ADObjectIdWithString item = new ADObjectIdWithString(stringValue, adobjectIdWithString.ObjectIdValue);
                supervisionListForADRecipient.Remove(adobjectIdWithString);
                supervisionListForADRecipient.Add(item);
            }
            else
            {
                string stringValue2        = this.Tag.ToLower();
                ADObjectIdWithString item2 = new ADObjectIdWithString(stringValue2, adRecipientToAdd.Id);
                supervisionListForADRecipient.Add(item2);
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.SupervisionListEntryAdded(this.Entry.ToString(), isGroup ? Strings.DistributionGroup : Strings.IndividualRecipient, this.Tag));
            }
        }
Exemple #29
0
        // Token: 0x06000B1E RID: 2846 RVA: 0x0004EC1C File Offset: 0x0004CE1C
        internal static string GetUserPrincipalName(string emailAddress, UserContext userContext)
        {
            string text = string.Empty;

            try
            {
                IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext);
                ProxyAddress      proxyAddress     = ProxyAddress.Parse(emailAddress);
                ADRecipient       adrecipient      = recipientSession.FindByProxyAddress(proxyAddress);
                if (adrecipient != null)
                {
                    text = adrecipient[ADUserSchema.UserPrincipalName].ToString();
                }
            }
            catch (Exception ex)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "IntantMessageUtilities.GetUserPrincipalName: Exception was thrown by User: {0}", ex.Message);
            }
            if (string.IsNullOrEmpty(text))
            {
                text = emailAddress;
            }
            return(text);
        }
        // Token: 0x06000A61 RID: 2657 RVA: 0x0004438C File Offset: 0x0004258C
        internal static ADRecipient GetADRecipient(Guid tenantGuid, string userLegacyDN)
        {
            ADSessionSettings sessionSettings = (tenantGuid == Guid.Empty) ? ADSessionSettings.FromRootOrgScopeSet() : ADSessionSettings.FromExternalDirectoryOrganizationId(tenantGuid);
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.PartiallyConsistent, sessionSettings, 48, "GetADRecipient", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\CalendarNotification\\Utils.cs");
            ADRecipient       result = null;

            try
            {
                result = tenantOrRootOrgRecipientSession.FindByLegacyExchangeDN(userLegacyDN);
            }
            catch (NonUniqueRecipientException)
            {
                Utils.Tracer.TraceError <string>((long)typeof(MailboxData).GetHashCode(), "User {0} AD object is not unique", userLegacyDN);
            }
            catch (ADTransientException)
            {
                Utils.Tracer.TraceError <string>((long)typeof(MailboxData).GetHashCode(), "Due to ADTransientException we can't get AD object for User {0} ", userLegacyDN);
            }
            catch (ADOperationException)
            {
                Utils.Tracer.TraceError <string>((long)typeof(MailboxData).GetHashCode(), "Due to ADOperationException we can't get AD object for User {0} ", userLegacyDN);
            }
            return(result);
        }