示例#1
0
 public static void DoAdCallAndTranslateExceptions(ADOperation call, bool expectObject, string debugContext)
 {
     Util.ThrowOnNullArgument(call, "call");
     try
     {
         ADNotificationAdapter.RunADOperation(call);
     }
     catch (DataValidationException innerException)
     {
         if (expectObject)
         {
             throw new ObjectNotFoundException(ServerStrings.ADUserNotFound, innerException);
         }
     }
     catch (DataSourceOperationException ex)
     {
         throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "MigrationHelperBase::{0}. Failed for [{1}], due to directory exception.", new object[]
         {
             ex,
             debugContext
         });
     }
     catch (DataSourceTransientException ex2)
     {
         throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "MigrationHelperBase::{0}. Failed for [{1}], due to directory exception.", new object[]
         {
             ex2,
             debugContext
         });
     }
 }
        private void SaveCultures(IRecipientSession adRecipientSession)
        {
            PreferredCultures preferredCultures = new PreferredCultures(base.Principal.PreferredCultures);

            preferredCultures.AddSupportedCulture(this.Language, (CultureInfo culture) => true);
            ADUser aduser = adRecipientSession.Read(base.Principal.ObjectId) as ADUser;

            if (aduser != null)
            {
                aduser.Languages.Clear();
                Util.AddRange <CultureInfo, CultureInfo>(aduser.Languages, preferredCultures);
                try
                {
                    adRecipientSession.Save(aduser);
                }
                catch (DataValidationException innerException)
                {
                    throw new CorruptDataException(ServerStrings.ExCannotSaveInvalidObject(aduser), innerException);
                }
                catch (DataSourceOperationException ex)
                {
                    throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, null, "MailboxRegionalConfiguration::SaveCultures. Failed due to directory exception {0}.", new object[]
                    {
                        ex
                    });
                }
                catch (DataSourceTransientException ex2)
                {
                    throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, null, "MailboxRegionalConfiguration::SaveCultures. Failed due to directory exception {0}.", new object[]
                    {
                        ex2
                    });
                }
            }
        }