我收到错误:
移动少数用户时随机移动未处理的类型' System.AccessViolationException'发生在System.DirectoryServices.dll
中
奇怪的是,似乎没有任何押韵或理由,当它们发生时,我有一个尝试,并且由于某种原因最近它开始崩溃应用程序。在调试器中,它们弹出,你可以继续它们并完成线程,"失败"行动起作用,并在下一个周期重新开始行动。
< - Code Snip it - >
If Action_Exe = "Update" Then
If IsDBNull(Processing_DataResults.Rows.Item(Master_Loop)(16)) Then
Trace.WriteLine("Error in datatable. NULL found.")
Trace.WriteLine("Record: " & Master_Loop)
Trace.WriteLine("User: " & Processing_DataResults.Rows.Item(Master_Loop)(1))
Trace.WriteLine("AD Current Path: " & newUser.Path)
'Update to try again
CycleSQLQUERY.CommandText = "UPDATE [dbo].[AMS_Processing_Table] SET [Process_FLAG] = 3 WHERE [TrackingID] = '" & Processing_DataResults.Rows.Item(Master_Loop)(0).ToString & "';"
WinEventLog.WriteEntry("Account Processing Thread: Null Var Found in Datatable. - " & Processing_DataResults.Rows.Item(Master_Loop)(1) & "-" & Master_Loop, EventLogEntryType.FailureAudit, 1614)
Continue For
End If
Trace.WriteLine("OLD: " & Replace(newUser.Path, newUser.Name & ",", ""))
Trace.WriteLine("New: " & LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/"))
If LCase(Replace(newUser.Path, newUser.Name & ",", "")) <> LCase(LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/")) Then
Thread.Sleep(100)
Dim UserObjPath As String = newUser.Path
Dim SuccessfulMove As Boolean = True
Try
newUser.MoveTo(New DirectoryEntry(LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/")))
Catch CatchALL As Exception
Trace.WriteLine(CatchALL.GetType)
Trace.WriteLine("OLD: " & Replace(newUser.Path, newUser.Name & ",", ""))
Trace.WriteLine("New: " & LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/"))
WinEventLog.WriteEntry("Account Processing Thread: Failed to move user object in AD. - " & Processing_DataResults.Rows.Item(Master_Loop)(1) & " - " & CatchALL.Message & "; OLD: " & LCase(Replace(newUser.Path, newUser.Name & ",", "")) & "; NEW:" & LCase(LDAPSpecial & Replace(Processing_DataResults.Rows.Item(Master_Loop)(16), "/", "\/")), EventLogEntryType.FailureAudit, 1611)
SuccessfulMove = False
CycleSQLQUERY.CommandText = "UPDATE [dbo].[AMS_Processing_Table] SET [Process_FLAG] = 3 WHERE [TrackingID] = '" & Processing_DataResults.Rows.Item(Master_Loop)(0).ToString & "';"
Try
CycleSQLQUERY.ExecuteNonQuery()
Catch ex_SQL As Exception
'addin 5/3/16
End Try
Continue For
End Try
If SuccessfulMove = True Then
Dim ChangeLineCount As Int64
尽管如此,建议,提示或修复将不胜感激。 这是一个多线程应用程序,特别是这部分。我试图拨打线程数和同样的问题。
答案 0 :(得分:0)
所以,我发现了我的问题,其他任何人都遇到了这个问题。 正在发生的事情发生在我之前在代码中连接到AD(只有域名)的代码中,如果操作是一个移动它将运行上面的代码,创建一个新的AD连接。连接到活动目录时,它将选择一个可用的域控制器(所需的操作),如果DC发生故障或负载太大而无法处理额外负载,这将非常有用。 无论如何,第二个连接有时会连接到另一个DC。如果两个连接都不在同一个DC上,它就会出错,很可能是因为这些变化还没有被复制到那个DC,因为它们刚刚发生在不到一秒钟之前。 所以,我对这个问题的解决方法是通过从LDAP中提取dnshostname并在第二个连接中使用它来加载第一个连接正在使用的dc。