示例#1
0
 public static void SetResolveUsers(AdminAuditLogSearch searchObject, DataAccessHelper.GetDataObjectDelegate getDataObject, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskWarningLoggingDelegate writeWarning)
 {
     if (searchObject.UserIdsUserInput != null && searchObject.UserIdsUserInput.Count > 0)
     {
         writeVerbose(Strings.VerboseStartResolvingUsers);
         ADObjectId        rootOrgContainerIdForLocalForest = ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest();
         ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(rootOrgContainerIdForLocalForest, searchObject.OrganizationId, null, false);
         IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.PartiallyConsistent, sessionSettings, 515, "SetResolveUsers", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\AdminAuditLog\\AdminAuditLogHelper.cs");
         tenantOrRootOrgRecipientSession.UseConfigNC = false;
         searchObject.UserIds       = new MultiValuedProperty <string>();
         searchObject.ResolvedUsers = new MultiValuedProperty <string>();
         foreach (SecurityPrincipalIdParameter securityPrincipalIdParameter in searchObject.UserIdsUserInput)
         {
             searchObject.UserIds.Add(securityPrincipalIdParameter.RawIdentity);
             bool flag = false;
             try
             {
                 ADRecipient adrecipient = (ADRecipient)getDataObject(securityPrincipalIdParameter, tenantOrRootOrgRecipientSession, null, null, new LocalizedString?(Strings.WarningSearchUserNotFound(securityPrincipalIdParameter.ToString())), new LocalizedString?(Strings.ErrorSearchUserNotUnique(securityPrincipalIdParameter.ToString())));
                 if (adrecipient.Id != null && adrecipient.Id.DomainId != null && !string.IsNullOrEmpty(adrecipient.Id.DomainId.Name))
                 {
                     string text = (string)adrecipient.propertyBag[IADSecurityPrincipalSchema.SamAccountName];
                     if (!string.IsNullOrEmpty(text))
                     {
                         searchObject.ResolvedUsers.Add(adrecipient.Id.DomainId.Name + "\\" + text);
                         flag = true;
                         writeVerbose(Strings.DebugResolvingDomainAccount(securityPrincipalIdParameter.ToString(), adrecipient.Id.DomainId.Name, text));
                     }
                 }
                 if (adrecipient.propertyBag[IADSecurityPrincipalSchema.Sid] != null)
                 {
                     string value = ((SecurityIdentifier)adrecipient.propertyBag[IADSecurityPrincipalSchema.Sid]).Value;
                     if (!string.IsNullOrEmpty(value))
                     {
                         searchObject.ResolvedUsers.Add(value);
                         flag = true;
                         writeVerbose(Strings.DebugResolvingUserSid(securityPrincipalIdParameter.ToString(), value));
                     }
                 }
                 if (adrecipient.Id != null && !string.IsNullOrEmpty(adrecipient.Id.ToString()))
                 {
                     searchObject.ResolvedUsers.Add(adrecipient.Id.ToString());
                     flag = true;
                     writeVerbose(Strings.DebugResolvingUserCN(securityPrincipalIdParameter.ToString(), adrecipient.Id.ToString()));
                 }
                 if (!flag)
                 {
                     writeWarning(Strings.WarningCannotResolveUser(securityPrincipalIdParameter.ToString()));
                     searchObject.ResolvedUsers.Add(securityPrincipalIdParameter.ToString());
                 }
             }
             catch (ManagementObjectNotFoundException)
             {
                 writeWarning(Strings.WarningSearchUserNotFound(securityPrincipalIdParameter.ToString()));
                 searchObject.ResolvedUsers.Add(securityPrincipalIdParameter.ToString());
             }
         }
     }
 }
示例#2
0
 private static bool TryValidateFolderId(MailboxFolderIdParameter folderId, DataAccessHelper.GetDataObjectDelegate getUserHandler, DataAccessHelper.GetDataObjectDelegate getFolderHandler, IRecipientSession resolveUserSession, ADUser adUser, ManageInboxRule.ThrowTerminatingErrorDelegate errorHandler)
 {
     if (folderId != null)
     {
         if (folderId.RawOwner != null)
         {
             ADUser aduser = (ADUser)getUserHandler(folderId.RawOwner, resolveUserSession, null, null, new LocalizedString?(Strings.ErrorMailboxNotFound(folderId.RawOwner.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(folderId.RawOwner.ToString())));
             if (!aduser.Identity.Equals(adUser.Identity))
             {
                 errorHandler(new LocalizedException(Strings.ErrorConflictingMailboxFolder(adUser.Identity.ToString(), folderId.ToString())), ErrorCategory.InvalidOperation, null);
             }
         }
         if (folderId.InternalMailboxFolderId == null)
         {
             folderId.InternalMailboxFolderId = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(adUser.Id, folderId.RawFolderStoreId, folderId.RawFolderPath);
         }
         return(true);
     }
     return(false);
 }
示例#3
0
        internal static IConfigurable ResolveDataObject(IConfigDataProvider readOnlySession, IConfigDataProvider readOnlyConfigurationSession, IConfigDataProvider globalCatalogSession, IIdentityParameter identity, DataAccessHelper.GetDataObjectDelegate getDataObjectHandler, Task.TaskVerboseLoggingDelegate logHandler)
        {
            IConfigurable configurable   = null;
            ADObjectId    adobjectId     = null;
            ADObjectId    rootID         = RecipientTaskHelper.IsValidDistinguishedName(identity, out adobjectId) ? adobjectId.Parent : null;
            Exception     innerException = null;

            if (readOnlySession != null)
            {
                try
                {
                    configurable = getDataObjectHandler(identity, readOnlySession, rootID, null, null, new LocalizedString?(Strings.ErrorObjectNotUnique(identity.ToString())));
                }
                catch (ADTransientException ex)
                {
                    innerException = ex;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlySession.Source, ex.Message));
                }
                catch (ManagementObjectNotFoundException ex2)
                {
                    innerException = ex2;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlySession.Source, ex2.Message));
                }
            }
            if (configurable == null && readOnlyConfigurationSession != null)
            {
                try
                {
                    configurable = getDataObjectHandler(identity, readOnlyConfigurationSession, rootID, null, null, new LocalizedString?(Strings.ErrorObjectNotUnique(identity.ToString())));
                }
                catch (ADTransientException ex3)
                {
                    innerException = ex3;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlyConfigurationSession.Source, ex3.Message));
                }
                catch (ManagementObjectNotFoundException ex4)
                {
                    innerException = ex4;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), readOnlyConfigurationSession.Source, ex4.Message));
                }
            }
            if (configurable == null && globalCatalogSession != null)
            {
                try
                {
                    configurable = getDataObjectHandler(identity, globalCatalogSession, rootID, null, null, new LocalizedString?(Strings.ErrorObjectNotUnique(identity.ToString())));
                }
                catch (ADTransientException ex5)
                {
                    innerException = ex5;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), globalCatalogSession.Source, ex5.Message));
                }
                catch (ManagementObjectNotFoundException ex6)
                {
                    innerException = ex6;
                    logHandler(Strings.VerboseCannotReadObject(identity.ToString(), globalCatalogSession.Source, ex6.Message));
                }
            }
            if (configurable == null)
            {
                throw new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(identity.ToString()), innerException);
            }
            return(configurable);
        }
示例#4
0
        public static IConfigDataProvider GetDataProviderForCallAnsweringRuleTasks(UMCallAnsweringRuleIdParameter identityParam, MailboxIdParameter mailboxParam, ADSessionSettings sessionSettings, IRecipientSession globalCatalogSession, ADObjectId executingUserId, string clientString, DataAccessHelper.GetDataObjectDelegate getDataObjectDelegate, Task.TaskErrorLoggingDelegate errorLogger)
        {
            ValidateArgument.NotNull(sessionSettings, "sessionSettings");
            ValidateArgument.NotNull(globalCatalogSession, "globalCatalogSession");
            ValidateArgument.NotNull(getDataObjectDelegate, "getDataObjectDelegate");
            ValidateArgument.NotNull(errorLogger, "errorLogger");
            ValidateArgument.NotNullOrEmpty(clientString, "clientString");
            MailboxIdParameter mailboxIdParameter = null;
            ADUser             aduser             = null;

            if (identityParam != null)
            {
                if (identityParam.CallAnsweringRuleId != null)
                {
                    mailboxIdParameter = new MailboxIdParameter(identityParam.CallAnsweringRuleId.MailboxOwnerId);
                }
                else
                {
                    mailboxIdParameter = identityParam.RawMailbox;
                }
            }
            if (mailboxIdParameter != null && mailboxParam != null)
            {
                errorLogger(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, identityParam);
            }
            if (mailboxIdParameter == null && executingUserId == null)
            {
                errorLogger(new RecipientTaskException(Strings.ErrorParameterRequired("Mailbox")), ErrorCategory.InvalidOperation, null);
            }
            if (mailboxIdParameter == null)
            {
                mailboxIdParameter = (mailboxParam ?? new MailboxIdParameter(executingUserId));
            }
            aduser = (ADUser)getDataObjectDelegate(mailboxIdParameter, globalCatalogSession, null, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString())));
            if (identityParam != null && identityParam.CallAnsweringRuleId == null)
            {
                identityParam.CallAnsweringRuleId = new UMCallAnsweringRuleId(aduser.Id, (identityParam.RawRuleGuid != null) ? identityParam.RawRuleGuid.Value : Guid.Empty);
            }
            ADScopeException ex;

            if (!globalCatalogSession.TryVerifyIsWithinScopes(aduser, true, out ex))
            {
                errorLogger(new InvalidOperationException(Strings.ErrorCannotChangeMailboxOutOfWriteScope(aduser.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ErrorCategory.InvalidOperation, aduser.Identity);
            }
            UMCallAnsweringRuleDataProvider result = null;

            try
            {
                result = new UMCallAnsweringRuleDataProvider(sessionSettings, aduser, clientString);
            }
            catch (UMRecipientValidationException)
            {
                errorLogger(new InvalidOperationException(Strings.MailboxNotUmEnabled(aduser.Identity.ToString())), ErrorCategory.InvalidOperation, aduser.Identity);
            }
            return(result);
        }
示例#5
0
 internal ADSite GetADSite(AdSiteIdParameter siteId, ITopologyConfigurationSession session, DataAccessHelper.GetDataObjectDelegate getDataObject)
 {
     this.writeVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(siteId, session, typeof(ADSite), session.GetConfigurationNamingContext().GetChildId("Sites")));
     return((ADSite)getDataObject(siteId, session, null, null, new LocalizedString?(Strings.ErrorSiteNotFound(siteId.ToString())), new LocalizedString?(Strings.ErrorSiteNotUnique(siteId.ToString()))));
 }
示例#6
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);
        }
        private static void ValidateMailbox(LocalizedString setting, string mailbox, ADObjectId dialPlanId, IRecipientSession recipSession, DataAccessHelper.GetDataObjectDelegate getUniqueObject, out string legacyDN)
        {
            legacyDN = null;
            ADRecipient adrecipient = (ADRecipient)getUniqueObject(new MailboxIdParameter(mailbox), recipSession, null, null, new LocalizedString?(Strings.InvalidMailbox(mailbox, setting)), new LocalizedString?(Strings.InvalidMailbox(mailbox, setting)));
            ADUser      aduser      = adrecipient as ADUser;

            if (!Utils.IsUserUMEnabledInGivenDialplan(aduser, dialPlanId))
            {
                throw new InvalidCustomMenuException(Strings.InvalidMailbox(mailbox, setting));
            }
            legacyDN = aduser.LegacyExchangeDN;
        }
        internal static void ValidateCustomMenu(LocalizedString setting, IConfigurationSession session, string property, MultiValuedProperty <CustomMenuKeyMapping> customMenu, int numberOfDigitsInExtension, UMAutoAttendant containingAutoAttendant, DataAccessHelper.GetDataObjectDelegate getUniqueObject, out bool serializeAgain)
        {
            serializeAgain = false;
            new List <string>();
            IRecipientSession recipientSessionScopedToOrganization = Utility.GetRecipientSessionScopedToOrganization(containingAutoAttendant.OrganizationId, true);

            foreach (CustomMenuKeyMapping customMenuKeyMapping in customMenu)
            {
                if (!string.IsNullOrEmpty(customMenuKeyMapping.AutoAttendantName))
                {
                    ValidationHelper.ValidateLinkedAutoAttendant(session, customMenuKeyMapping.AutoAttendantName, containingAutoAttendant.Status == StatusEnum.Enabled, containingAutoAttendant);
                }
                string text = Utils.TrimSpaces(customMenuKeyMapping.PromptFileName);
                if (text != null)
                {
                    ValidationHelper.ValidateWavFile(text);
                }
                if (!string.IsNullOrEmpty(customMenuKeyMapping.LeaveVoicemailFor))
                {
                    string legacyDNToUseForLeaveVoicemailFor;
                    ValidationHelper.ValidateMailbox(setting, customMenuKeyMapping.LeaveVoicemailFor, containingAutoAttendant.UMDialPlan, recipientSessionScopedToOrganization, getUniqueObject, out legacyDNToUseForLeaveVoicemailFor);
                    customMenuKeyMapping.LegacyDNToUseForLeaveVoicemailFor = legacyDNToUseForLeaveVoicemailFor;
                    serializeAgain = true;
                }
                if (!string.IsNullOrEmpty(customMenuKeyMapping.TransferToMailbox))
                {
                    string legacyDNToUseForTransferToMailbox;
                    ValidationHelper.ValidateMailbox(setting, customMenuKeyMapping.TransferToMailbox, containingAutoAttendant.UMDialPlan, recipientSessionScopedToOrganization, getUniqueObject, out legacyDNToUseForTransferToMailbox);
                    customMenuKeyMapping.LegacyDNToUseForTransferToMailbox = legacyDNToUseForTransferToMailbox;
                    serializeAgain = true;
                }
            }
            CustomMenuKeyMapping[]           array       = customMenu.ToArray();
            Dictionary <string, int>         dictionary  = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase);
            Dictionary <CustomMenuKey, bool> dictionary2 = new Dictionary <CustomMenuKey, bool>();

            for (int i = 0; i < array.Length; i++)
            {
                CustomMenuKeyMapping customMenuKeyMapping2 = array[i];
                try
                {
                    dictionary.Add(customMenuKeyMapping2.Description, i);
                }
                catch (ArgumentException)
                {
                    throw new InvalidCustomMenuException(Strings.DuplicateMenuName(customMenuKeyMapping2.Description));
                }
                if (!string.IsNullOrEmpty(customMenuKeyMapping2.AsrPhrases) && customMenuKeyMapping2.AsrPhrases.Length > 256)
                {
                    throw new InvalidCustomMenuException(Strings.MaxAsrPhraseLengthExceeded(customMenuKeyMapping2.Description));
                }
                string[] asrPhraseList = customMenuKeyMapping2.AsrPhraseList;
                if (asrPhraseList != null)
                {
                    if (asrPhraseList.Length > 9)
                    {
                        throw new InvalidCustomMenuException(Strings.MaxAsrPhraseCountExceeded(customMenuKeyMapping2.Description));
                    }
                    for (int j = 0; j < asrPhraseList.Length; j++)
                    {
                        if (string.IsNullOrEmpty(asrPhraseList[j]))
                        {
                            throw new InvalidCustomMenuException(Strings.EmptyASRPhrase(customMenuKeyMapping2.Description));
                        }
                        try
                        {
                            dictionary.Add(asrPhraseList[j], -1);
                        }
                        catch (ArgumentException)
                        {
                            if (dictionary[asrPhraseList[j]] != i)
                            {
                                throw new InvalidCustomMenuException(Strings.DuplicateASRPhrase(asrPhraseList[j]));
                            }
                        }
                    }
                }
                try
                {
                    if (customMenuKeyMapping2.MappedKey != CustomMenuKey.NotSpecified)
                    {
                        dictionary2.Add(customMenuKeyMapping2.MappedKey, true);
                    }
                }
                catch (ArgumentException)
                {
                    throw new InvalidCustomMenuException(Strings.DuplicateKeys(customMenuKeyMapping2.Key));
                }
            }
        }
示例#9
0
        public static ADRecipientOrAddress[] ResolveRecipients(IList <RecipientIdParameter> recipientIDs, DataAccessHelper.GetDataObjectDelegate getRecipientObject, IRecipientSession recipientSession, ManageInboxRule.ThrowTerminatingErrorDelegate errorHandler)
        {
            if (recipientIDs == null || recipientIDs.Count == 0)
            {
                return(null);
            }
            ADRecipientOrAddress[] array = new ADRecipientOrAddress[recipientIDs.Count];
            int num = 0;

            foreach (RecipientIdParameter recipientIdParameter in recipientIDs)
            {
                try
                {
                    recipientIdParameter.SearchWithDisplayName = false;
                    ADRecipient adEntry = (ADRecipient)getRecipientObject(recipientIdParameter, recipientSession, null, null, new LocalizedString?(Strings.ErrorRecipientNotFound(recipientIdParameter.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(recipientIdParameter.ToString())));
                    array[num++] = new ADRecipientOrAddress(new Participant(adEntry));
                }
                catch (ManagementObjectNotFoundException)
                {
                    MimeRecipient mimeRecipient = null;
                    try
                    {
                        mimeRecipient = MimeRecipient.Parse(recipientIdParameter.RawIdentity, AddressParserFlags.IgnoreComments | AddressParserFlags.AllowSquareBrackets);
                    }
                    catch (MimeException)
                    {
                    }
                    if (mimeRecipient == null || string.IsNullOrEmpty(mimeRecipient.Email) || !SmtpAddress.IsValidSmtpAddress(mimeRecipient.Email))
                    {
                        errorHandler(new LocalizedException(Strings.ErrorInboxRuleUserInvalid(recipientIdParameter.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    string text = string.Empty;
                    try
                    {
                        text = mimeRecipient.DisplayName;
                    }
                    catch (MimeException)
                    {
                    }
                    if (string.IsNullOrEmpty(text))
                    {
                        text = mimeRecipient.Email;
                    }
                    array[num++] = new ADRecipientOrAddress(new Participant(text, mimeRecipient.Email, "smtp"));
                }
            }
            return(array);
        }
示例#10
0
        public static MailboxFolder ResolveMailboxFolder(MailboxFolderIdParameter folderId, DataAccessHelper.GetDataObjectDelegate getUserHandler, DataAccessHelper.GetDataObjectDelegate getFolderHandler, IRecipientSession resolveUserSession, ADSessionSettings sessionSettings, ADUser adUser, ManageInboxRule.ThrowTerminatingErrorDelegate errorHandler)
        {
            if (!ManageInboxRule.TryValidateFolderId(folderId, getUserHandler, getFolderHandler, resolveUserSession, adUser, errorHandler))
            {
                return(null);
            }
            MailboxFolder result;

            using (MailboxFolderDataProvider mailboxFolderDataProvider = new MailboxFolderDataProvider(sessionSettings, adUser, "ResolveMailboxFolder"))
            {
                result = (MailboxFolder)getFolderHandler(folderId, mailboxFolderDataProvider, null, null, new LocalizedString?(Strings.ErrorMailboxFolderNotFound(folderId.ToString())), new LocalizedString?(Strings.ErrorMailboxFolderNotUnique(folderId.ToString())));
            }
            return(result);
        }
示例#11
0
 internal static Server GetServerObject(ServerIdParameter serverIdParameter, IConfigurationSession dataSession, ObjectId rootId, DataAccessHelper.GetDataObjectDelegate getDataObjectServer)
 {
     return((Server)getDataObjectServer(serverIdParameter, dataSession, rootId, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString()))));
 }