Exemplo n.º 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
         });
     }
 }
Exemplo n.º 2
0
 // Token: 0x06000366 RID: 870 RVA: 0x00012968 File Offset: 0x00010B68
 public static void RunADOperation(ADOperation adOperation, int retryCount)
 {
     if (adOperation == null)
     {
         throw new ArgumentNullException("adOperation");
     }
     if (retryCount < 0)
     {
         throw new ArgumentOutOfRangeException("retryCount", "Number of retries must be equal to or larger than zero.");
     }
     for (int i = 0; i <= retryCount; i++)
     {
         try
         {
             adOperation();
             break;
         }
         catch (ADInvalidCredentialException ex)
         {
             if (i == retryCount)
             {
                 throw new ADTransientException(ex.LocalizedString, ex);
             }
         }
         catch (TransientException)
         {
             if (i == retryCount)
             {
                 throw;
             }
         }
         Thread.Sleep(i * 1000);
     }
 }
        // Token: 0x0600108F RID: 4239 RVA: 0x00060D40 File Offset: 0x0005EF40
        private ADOperationResult TryRunPerGroupADOperation(ADOperation adOperation, string groupDN)
        {
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(adOperation, 3);

            switch (adoperationResult.ErrorCode)
            {
            case ADOperationErrorCode.RetryableError:
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_GroupExpansionHaltedWarning, this.GetOrganizationIdString(), new object[]
                {
                    adoperationResult.Exception.GetType().Name,
                    groupDN,
                    adoperationResult.Exception
                });
                break;

            case ADOperationErrorCode.PermanentError:
                GroupMetricsGenerator.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_GroupExpansionHaltedError, this.GetOrganizationIdString(), new object[]
                {
                    adoperationResult.Exception.GetType().Name,
                    groupDN,
                    adoperationResult.Exception
                });
                break;
            }
            return(adoperationResult);
        }
Exemplo n.º 4
0
 private void RunADOperation(object group, ADOperation adOperation)
 {
     try
     {
         ADNotificationAdapter.RunADOperation(adOperation);
     }
     catch (TransientException e)
     {
         this.RethrowException(group, e);
     }
     catch (DataValidationException e2)
     {
         this.RethrowException(group, e2);
     }
 }
Exemplo n.º 5
0
        // Token: 0x0600132D RID: 4909 RVA: 0x0006F36C File Offset: 0x0006D56C
        public static Exception RunSafeADOperation(ADOperation adOperation, string details)
        {
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(adOperation, 5);

            if (!adoperationResult.Succeeded)
            {
                OABLogger.LogRecord(TraceType.ErrorTrace, "RunSafeADOperation failed with ErrorCode: {0}, Exception: {1}. Operation Details: {2}", new object[]
                {
                    adoperationResult.ErrorCode,
                    adoperationResult.Exception,
                    string.IsNullOrEmpty(details) ? "null" : details
                });
                return(adoperationResult.Exception);
            }
            return(null);
        }
Exemplo n.º 6
0
        private bool TryRunADOperation(ADOperation operation, bool throwExceptions)
        {
            int retryCount = 3;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                operation();
            }, retryCount);

            if (adoperationResult.Exception == null)
            {
                return(adoperationResult.Succeeded);
            }
            if (!throwExceptions)
            {
                ExTraceGlobals.ExceptionTracer.TraceError <Exception>((long)this.GetHashCode(), "Failed to run AD operation: {0}", adoperationResult.Exception);
                return(false);
            }
            throw adoperationResult.Exception;
        }
Exemplo n.º 7
0
 // Token: 0x06000368 RID: 872 RVA: 0x000129FC File Offset: 0x00010BFC
 public static ADOperationResult TryRunADOperation(ADOperation adOperation, int retryCount)
 {
     try
     {
         ADNotificationAdapter.RunADOperation(adOperation, retryCount);
     }
     catch (TransientException ex)
     {
         ExTraceGlobals.ADNotificationsTracer.TraceDebug <TransientException>(0L, "AD operation failed with exception: {0}", ex);
         return(new ADOperationResult(ADOperationErrorCode.RetryableError, ex));
     }
     catch (DataSourceOperationException ex2)
     {
         ExTraceGlobals.ADNotificationsTracer.TraceDebug <DataSourceOperationException>(0L, "AD operation failed with exception: {0}", ex2);
         return(new ADOperationResult(ADOperationErrorCode.PermanentError, ex2));
     }
     catch (DataValidationException ex3)
     {
         ExTraceGlobals.ADNotificationsTracer.TraceDebug <DataValidationException>(0L, "AD operation failed with exception: {0}", ex3);
         return(new ADOperationResult(ADOperationErrorCode.PermanentError, ex3));
     }
     return(ADOperationResult.Success);
 }
Exemplo n.º 8
0
        public bool Authenticate(string password, AuthenticationOption option)
        {
            if (option == null)
            {
                return(false);
            }

            try
            {
                LdapConnection con = new LdapConnection(option.ConnectionString);
                switch (option.Mode)
                {
                case AuthenticationMode.None:
                case AuthenticationMode.Anonymous:
                    con.AuthType = AuthType.Anonymous;
                    break;

                case AuthenticationMode.Basic:
                    con.Credential = new NetworkCredential(option.ServiceAccountName, option.ServiceAccountPwd);
                    con.AuthType   = AuthType.Basic;
                    break;

                case AuthenticationMode.secure:
                    con.Credential = new NetworkCredential(
                        ADOperation.GetAccountName(option.ServiceAccountName),
                        option.ServiceAccountPwd,
                        ADOperation.GetDomainName(option.ServiceAccountName));
                    con.AuthType = AuthType.Ntlm;
                    break;

                default:
                    throw new NotImplementedException();
                }

                using (con)
                {
                    con.Bind();

                    string filter = option.BuildSearchFilter();
                    if (string.IsNullOrEmpty(filter))
                    {
                        return(false);
                    }

                    System.DirectoryServices.Protocols.SearchRequest request = new System.DirectoryServices.Protocols.SearchRequest(
                        option.GetSearchRoot(),
                        filter,
                        System.DirectoryServices.Protocols.SearchScope.Subtree);

                    SearchResponse response = (SearchResponse)con.SendRequest(request);
                    if (response.Entries.Count != 1)
                    {
                        return(false);
                    }
                    SearchResultEntry entry = response.Entries[0];
                    string            dn    = entry.DistinguishedName;

                    con.Credential = new NetworkCredential(dn, password);
                    con.AuthType   = AuthType.Basic;
                    con.Bind();
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
 // Token: 0x06000367 RID: 871 RVA: 0x000129F0 File Offset: 0x00010BF0
 public static ADOperationResult TryRunADOperation(ADOperation adOperation)
 {
     return(ADNotificationAdapter.TryRunADOperation(adOperation, 10));
 }
Exemplo n.º 10
0
 // Token: 0x06000365 RID: 869 RVA: 0x0001295C File Offset: 0x00010B5C
 public static void RunADOperation(ADOperation adOperation)
 {
     ADNotificationAdapter.RunADOperation(adOperation, 10);
 }
 // Token: 0x06000046 RID: 70 RVA: 0x0000298D File Offset: 0x00000B8D
 private void DoAdCallAndTranslateExceptions(ADOperation call, bool expectObject)
 {
     MigrationHelperBase.DoAdCallAndTranslateExceptions(call, expectObject, this.DebugInfo);
 }