Пример #1
0
        internal static bool ResetUMPin(ADUser aduser, string passwd)
        {
            UmConnectivityCredentialsHelper.DebugTrace("Inside UmConnectivityCredentialsHelper: ResetUMPin", new object[0]);
            string pin;

            try
            {
                UMMailboxPolicy policyFromUser = Utility.GetPolicyFromUser(aduser);
                if (!UmConnectivityCredentialsHelper.GetRandomPINFromPasswd(passwd, policyFromUser.MinPINLength, out pin))
                {
                    UmConnectivityCredentialsHelper.DebugTrace("Inside ResetUMPin(): didnt get pin", new object[0]);
                    return(false);
                }
            }
            catch (LocalizedException ex)
            {
                UmConnectivityCredentialsHelper.DebugTrace("Inside ResetUMPin(): got Exception = {0}", new object[]
                {
                    ex.ToString()
                });
                return(false);
            }
            LocalizedException ex2 = UmConnectivityCredentialsHelper.SaveUMPin(aduser, pin);

            if (ex2 != null)
            {
                UmConnectivityCredentialsHelper.DebugTrace("Inside ResetUMPin(): SaveUMPin Exception = {0}", new object[]
                {
                    ex2.ToString()
                });
                return(false);
            }
            return(true);
        }
Пример #2
0
        private bool GeneratePinFromPassword()
        {
            UmConnectivityCredentialsHelper.DebugTrace("Inside GeneratePinFromPassword()", new object[0]);
            NetworkCredential networkCredential = new NetworkCredential(this.userName, string.Empty, this.domain);

            if (!UmConnectivityCredentialsHelper.FindPassword(this.exp, networkCredential))
            {
                UmConnectivityCredentialsHelper.DebugTrace("Inside GeneratePinFromPassword(): didnt find passwd", new object[0]);
                return(false);
            }
            try
            {
                UMMailboxPolicy policyFromUser = Utility.GetPolicyFromUser(this.aduser);
                if (!UmConnectivityCredentialsHelper.GetRandomPINFromPasswd(networkCredential.Password, policyFromUser.MinPINLength, out this.umPin))
                {
                    UmConnectivityCredentialsHelper.DebugTrace("Inside GeneratePinFromPassword(): didnt get pin", new object[0]);
                    return(false);
                }
            }
            catch (LocalizedException ex)
            {
                UmConnectivityCredentialsHelper.DebugTrace("Inside GeneratePinFromPassword(): got Exception = {0}", new object[]
                {
                    ex.ToString()
                });
                return(false);
            }
            return(true);
        }
Пример #3
0
        private UMMailboxPolicy AutoGeneratePolicy()
        {
            UMMailboxPolicy ummailboxPolicy = new UMMailboxPolicy();

            ummailboxPolicy.UMDialPlan = this.DataObject.Id;
            if (this.DataObject.SubscriberType == UMSubscriberType.Consumer)
            {
                ummailboxPolicy.AllowDialPlanSubscribers = false;
                ummailboxPolicy.AllowExtensions          = false;
            }
            ADObjectId descendantId  = base.CurrentOrgContainerId.GetDescendantId(new ADObjectId("CN=UM Mailbox Policies", Guid.Empty));
            AdName     adName        = new AdName("CN", this.defaultPolicyName);
            ADObjectId descendantId2 = descendantId.GetDescendantId(new ADObjectId(adName.ToString(), Guid.Empty));

            ummailboxPolicy.SetId(descendantId2);
            if (base.CurrentOrganizationId != null)
            {
                ummailboxPolicy.OrganizationId = base.CurrentOrganizationId;
            }
            else
            {
                ummailboxPolicy.OrganizationId = base.ExecutingUserOrganizationId;
            }
            ummailboxPolicy.SourceForestPolicyNames.Add(adName.EscapedName);
            base.CreateParentContainerIfNeeded(ummailboxPolicy);
            base.DataSession.Save(ummailboxPolicy);
            return(ummailboxPolicy);
        }
Пример #4
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADUser aduser = (ADUser)base.PrepareDataObject();

            if ((aduser.UMEnabledFlags & UMEnabledFlags.UMEnabled) != UMEnabledFlags.UMEnabled)
            {
                base.WriteError(new RecipientTaskException(Strings.MailboxNotUmEnabled(this.Identity.ToString())), (ErrorCategory)1000, aduser);
            }
            if (base.UMMailboxPolicy != null)
            {
                IConfigurationSession configurationSession = this.ConfigurationSession;
                ADObjectId            ummailboxPolicy      = aduser.UMMailboxPolicy;
                if (ummailboxPolicy != null)
                {
                    MailboxPolicyIdParameter id = new MailboxPolicyIdParameter(ummailboxPolicy);
                    UMMailboxPolicy          ummailboxPolicy2 = (UMMailboxPolicy)base.GetDataObject <UMMailboxPolicy>(id, configurationSession, null, new LocalizedString?(Strings.ErrorManagedFolderMailboxPolicyNotFound(ummailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorManagedFolderMailboxPolicyNotUnique(ummailboxPolicy.ToString())));
                    if (!ummailboxPolicy2.UMDialPlan.Equals(this.newMailboxPolicy.UMDialPlan))
                    {
                        base.WriteError(new RecipientTaskException(Strings.NewPolicyMustBeInTheSameDialPlanAsOldPolicy(ummailboxPolicy2.UMDialPlan.Name)), (ErrorCategory)1000, aduser);
                    }
                }
                aduser.UMMailboxPolicy = this.newMailboxPolicy.Id;
            }
            if (base.Fields.IsModified("PhoneNumber"))
            {
                this.SetPhoneNumber(aduser);
            }
            if (base.Fields.IsModified("AirSyncNumbers"))
            {
                this.SetAirSyncNumber(aduser);
            }
            TaskLogger.LogExit();
            return(aduser);
        }
Пример #5
0
        // Token: 0x06000ABF RID: 2751 RVA: 0x00046714 File Offset: 0x00044914
        private bool TryReadUserConfiguration(MailboxInfo mailbox, out ADUser user, out UMDialPlan dialPlan, out bool sendSms, out bool sendMsgWaitingIndicator)
        {
            user     = null;
            dialPlan = null;
            sendSms  = false;
            sendMsgWaitingIndicator = false;
            IADRecipientLookup iadrecipientLookup = ADRecipientLookupFactory.CreateFromOrganizationId(mailbox.OrganizationId, null);

            user = (iadrecipientLookup.LookupByExchangeGuid(mailbox.Guid) as ADUser);
            if (user == null)
            {
                ExTraceGlobals.MWITracer.TraceError <Guid>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: Could not find ADUser for mailbox {0}", mailbox.Guid);
                return(false);
            }
            if (!user.UMEnabled || user.UMMailboxPolicy == null || user.UMRecipientDialPlanId == null)
            {
                ExTraceGlobals.MWITracer.TraceError((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: ({0}): Invalid user({1}) UMEnabled({2}) UMMbxPol({3}) DialPlan({4})", new object[]
                {
                    mailbox.Guid,
                    user.DistinguishedName,
                    user.UMEnabled,
                    user.UMMailboxPolicy,
                    user.UMRecipientDialPlanId
                });
                return(false);
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(user.UMMailboxPolicy), 1108, "TryReadUserConfiguration", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\mwi\\MwiAssistant.cs");
            UMMailboxPolicy       ummailboxPolicy = tenantOrTopologyConfigurationSession.Read <UMMailboxPolicy>(user.UMMailboxPolicy);

            if (ummailboxPolicy == null)
            {
                ExTraceGlobals.MWITracer.TraceError <ADObjectId, string>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: Could not find UMMailboxPolicy: {0}, User {1}", user.UMMailboxPolicy, user.DistinguishedName);
                return(false);
            }
            sendSms = ummailboxPolicy.AllowSMSNotification;
            sendMsgWaitingIndicator = ummailboxPolicy.AllowMessageWaitingIndicator;
            ExTraceGlobals.MWITracer.TraceDebug <bool, bool, string>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: AllowSMSNotification={0}, AllowMessageWaitingIndicator={1}, User {2}", sendSms, sendMsgWaitingIndicator, user.DistinguishedName);
            bool flag = sendSms || sendMsgWaitingIndicator;

            if (flag)
            {
                dialPlan = tenantOrTopologyConfigurationSession.Read <UMDialPlan>(user.UMRecipientDialPlanId);
                if (dialPlan == null)
                {
                    ExTraceGlobals.MWITracer.TraceError <ADObjectId>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration: Could not find UMDialPlan: {0}", user.UMRecipientDialPlanId);
                    return(false);
                }
                ExTraceGlobals.MWITracer.TraceDebug <string, ADObjectId, UMSubscriberType>((long)this.GetHashCode(), "MwiAssistant.TryReadUserConfiguration User {0} DialPlan{1}.SubscriberType={2}.", user.DistinguishedName, dialPlan.Id, dialPlan.SubscriberType);
            }
            return(flag);
        }
Пример #6
0
        private void SetAirSyncNumber(ADUser user)
        {
            UMMailboxPolicy ummailboxPolicy = this.ReadPolicyObject(user);
            UMDialPlan      dialPlan        = ummailboxPolicy.GetDialPlan();
            MultiValuedProperty <string> extensionsFromCollection = UMMailbox.GetExtensionsFromCollection(user.UMAddresses, ProxyAddressPrefix.ASUM, dialPlan.PhoneContext);
            Hashtable     hashtable = new Hashtable();
            List <string> list      = new List <string>();

            foreach (string key in extensionsFromCollection)
            {
                hashtable.Add(key, false);
            }
            foreach (string text in this.AirSyncNumbers)
            {
                if (hashtable.ContainsKey(text))
                {
                    hashtable[text] = true;
                }
                else
                {
                    list.Add(text);
                }
            }
            foreach (object obj in hashtable)
            {
                DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                if (!(bool)dictionaryEntry.Value)
                {
                    TelephoneNumberProcessStatus status;
                    AirSyncUtils.RemoveAirSyncPhoneNumber(user, (string)dictionaryEntry.Key, out status);
                    ArgumentException ex = this.HandleResult(status, (string)dictionaryEntry.Key);
                    if (ex != null)
                    {
                        base.WriteError(ex, (ErrorCategory)1001, null);
                    }
                }
            }
            foreach (string text2 in list)
            {
                TelephoneNumberProcessStatus status2;
                AirSyncUtils.AddAirSyncPhoneNumber(user, text2, out status2);
                ArgumentException ex2 = this.HandleResult(status2, text2);
                if (ex2 != null)
                {
                    base.WriteError(ex2, (ErrorCategory)1001, null);
                }
            }
        }
Пример #7
0
        private void SetPhoneNumber(ADUser user)
        {
            UMMailboxPolicy ummailboxPolicy = this.ReadPolicyObject(user);
            UMDialPlan      dialPlan        = ummailboxPolicy.GetDialPlan();

            if (dialPlan.URIType != UMUriType.E164 || dialPlan.SubscriberType != UMSubscriberType.Consumer)
            {
                base.WriteError(new ArgumentException(Strings.PhoneNumberAllowedOnlyOnE164ConsumerDialplan, "PhoneNumber"), (ErrorCategory)1000, null);
            }
            if (string.IsNullOrEmpty(dialPlan.CountryOrRegionCode))
            {
                base.WriteError(new ArgumentException(Strings.PhoneNumberAllowedOnlyWithDialplanWithCountryCode, "PhoneNumber"), (ErrorCategory)1000, null);
            }
            if (this.PhoneNumber == string.Empty)
            {
                Utils.UMPopulate(user, null, null, ummailboxPolicy, dialPlan);
                return;
            }
            PhoneNumber phoneNumber;

            if (!Microsoft.Exchange.UM.UMCommon.PhoneNumber.TryParse(this.PhoneNumber, out phoneNumber) || phoneNumber.UriType != UMUriType.TelExtn)
            {
                base.WriteError(new ArgumentException(Strings.PhoneNumberNotANumber(dialPlan.NumberOfDigitsInExtension), this.PhoneNumber), (ErrorCategory)1000, null);
            }
            string                       sipResourceIdentifier       = "+" + dialPlan.CountryOrRegionCode + phoneNumber.Number;
            IRecipientSession            tenantLocalRecipientSession = RecipientTaskHelper.GetTenantLocalRecipientSession(user.OrganizationId, base.ExecutingUserOrganizationId, base.RootOrgContainerId);
            LocalizedException           ex = null;
            TelephoneNumberProcessStatus telephoneNumberProcessStatus;

            Utils.ValidateExtensionsAndSipResourceIdentifier(tenantLocalRecipientSession, this.ConfigurationSession, CommonConstants.DataCenterADPresent, user, dialPlan, new string[]
            {
                phoneNumber.Number
            }, new string[]
            {
                this.PhoneNumber
            }, sipResourceIdentifier, out ex, out telephoneNumberProcessStatus);
            if (ex != null)
            {
                base.WriteError(ex, (ErrorCategory)1000, null);
            }
            if (telephoneNumberProcessStatus != TelephoneNumberProcessStatus.PhoneNumberAlreadyRegistered)
            {
                Utils.UMPopulate(user, sipResourceIdentifier, new MultiValuedProperty <string>(phoneNumber.Number), ummailboxPolicy, dialPlan);
            }
        }
Пример #8
0
        public static UMMailboxPolicy GetPolicyFromUser(ADUser user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (user.UMMailboxPolicy == null)
            {
                throw new UMMailboxPolicyNotPresentException(user.PrimarySmtpAddress.ToString());
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), user.OrganizationId, null, false), 164, "GetPolicyFromUser", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\um\\Utils.cs");
            UMMailboxPolicy       ummailboxPolicy = tenantOrTopologyConfigurationSession.Read <UMMailboxPolicy>(user.UMMailboxPolicy);

            if (ummailboxPolicy == null)
            {
                throw new UMMailboxPolicyIdNotFoundException(user.UMMailboxPolicy.Name.ToString());
            }
            return(ummailboxPolicy);
        }
Пример #9
0
        private static UMMailboxPolicy GetTargetPolicy(IConfigurationSession tenantLocalConfigSession, ADUser sourceUser)
        {
            UMMailboxPolicy ummailboxPolicy = null;

            UMMailboxPolicy[] array = tenantLocalConfigSession.Find <UMMailboxPolicy>(null, QueryScope.SubTree, null, null, 0);
            foreach (UMMailboxPolicy ummailboxPolicy2 in array)
            {
                if (ummailboxPolicy2.SourceForestPolicyNames.Contains(sourceUser.UMMailboxPolicy.Name))
                {
                    ummailboxPolicy = ummailboxPolicy2;
                    break;
                }
            }
            if (ummailboxPolicy == null)
            {
                throw new NoMatchingUMMailboxPolicyInTargetForestException();
            }
            return(ummailboxPolicy);
        }
Пример #10
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.CreateParentContainerIfNeeded(this.DataObject);
            if (CommonConstants.UseDataCenterCallRouting)
            {
                this.DataObject.PhoneContext = base.Name + "." + Guid.NewGuid().ToString("D");
            }
            else
            {
                this.DataObject.PhoneContext = base.Name + "." + ADForest.GetLocalForest().Fqdn;
            }
            if (this.DataObject.SubscriberType == UMSubscriberType.Consumer)
            {
                this.DataObject.CallSomeoneEnabled  = false;
                this.DataObject.SendVoiceMsgEnabled = false;
            }
            this.DataObject.AudioCodec = AudioCodecEnum.Mp3;
            UMMailboxPolicy ummailboxPolicy = null;

            if (base.Fields["GenerateUMMailboxPolicy"] == null || (bool)base.Fields["GenerateUMMailboxPolicy"])
            {
                base.DataSession.Save(this.DataObject);
                ummailboxPolicy = this.AutoGeneratePolicy();
            }
            base.InternalProcessRecord();
            if (!base.HasErrors)
            {
                UmGlobals.ExEvent.LogEvent(UMEventLogConstants.Tuple_NewDialPlanCreated, null, new object[]
                {
                    base.Name
                });
            }
            else if (ummailboxPolicy != null)
            {
                base.DataSession.Delete(ummailboxPolicy);
                base.DataSession.Delete(this.DataObject);
            }
            TaskLogger.LogExit();
        }
Пример #11
0
        internal static bool TryGetUMMailboxPolicy(Trace tracer, UMMailbox mailbox, out UMMailboxPolicy mailboxPolicy)
        {
            mailboxPolicy = null;
            if (!mailbox.UMEnabled || mailbox.UMMailboxPolicy == null)
            {
                tracer.TraceWarning <string>(0L, "Recipient is not UM enabled: {0}", mailbox.DistinguishedName);
                return(false);
            }
            UMMailboxPolicy policy = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), mailbox.OrganizationId, null, false);
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 117, "TryGetUMMailboxPolicy", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\agents\\UM\\UMAgentUtil.cs");
                policy = tenantOrTopologyConfigurationSession.Read <UMMailboxPolicy>(mailbox.UMMailboxPolicy);
            });
            if (policy == null)
            {
                tracer.TraceWarning <string, string>(0L, "Could not open mailbox policy {0} for {1}", mailbox.UMMailboxPolicy.DistinguishedName, mailbox.DistinguishedName);
                return(false);
            }
            mailboxPolicy = policy;
            return(true);
        }
Пример #12
0
        internal static bool TryGetUMMailboxPolicy(Trace tracer, ADRecipientCache <TransportMiniRecipient> recipientCache, MailRecipient mailRecipient, out UMMailboxPolicy mailboxPolicy)
        {
            mailboxPolicy = null;
            ADUser dataObject = null;

            return(UMAgentUtil.TryGetADUser(tracer, recipientCache, mailRecipient, out dataObject) && UMAgentUtil.TryGetUMMailboxPolicy(tracer, new UMMailbox(dataObject), out mailboxPolicy));
        }
Пример #13
0
        private static void GetUMSettingsFromSourceUser(IRecipientSession tenantLocalRecipientSession, IConfigurationSession tenantLocalConfigSession, bool isDatacenter, ADUser sourceUser, ADUser targetUser, out UMMailboxPolicy targetPolicy, out UMDialPlan targetDialPlan, out MultiValuedProperty <string> targetUserExtensions, out string targetUserSipResourceIdentifier)
        {
            if (!Utils.UnifiedMessagingAvailable(targetUser))
            {
                throw new UMNotAvailableForUserInTargetForestException();
            }
            targetPolicy         = MigrationHelper.GetTargetPolicy(tenantLocalConfigSession, sourceUser);
            targetDialPlan       = tenantLocalConfigSession.Read <UMDialPlan>(targetPolicy.UMDialPlan);
            targetUserExtensions = MigrationHelper.GetTargetUserExtensions(sourceUser, targetDialPlan, out targetUserSipResourceIdentifier);
            LocalizedException           ex;
            TelephoneNumberProcessStatus telephoneNumberProcessStatus;

            Utils.ValidateExtensionsAndSipResourceIdentifier(tenantLocalRecipientSession, tenantLocalConfigSession, isDatacenter, targetUser, targetDialPlan, targetUserExtensions.ToArray(), null, targetUserSipResourceIdentifier, out ex, out telephoneNumberProcessStatus);
            if (ex != null)
            {
                throw ex;
            }
        }