Active Directoryの役割を使用して、winfowmsアプリにVB.NETでVS2012を使用しています。権限のないユーザーとしてプログラムを実行すると、このフォームを起動しようとすると(予期される)セキュリティ例外が発生します。
私は次のようなフォームを持っています:
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.ADMINISTRATORS)> _
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.CORRECTIVE_ACTION_EDITORS)> _
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.GRIEVANCE_EDITORS)> _
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.ABOLISHMENT_EDITORS)> _
Public Class EmployeeInformationForm
...
End Class
コードの呼び出しは次のようになります。
Private Sub SendEmployeeIDToEmployeeInformationForm(ByVal ID_in As String, ByVal employeeRecord_in As String)
...
If Not formFound Then
' Create a new instance of the child form.
Dim ChildForm As New EmployeeInformationForm(ID_in, employeeRecord_in) ' ** throws expected security exception here**
Try
' Make it a child of this MDI form before showing it.
ChildForm.MdiParent = Me.MdiParent
...
ChildForm.Show()
Catch ex As Exception
ChildForm.Close()
Throw
End Try
End If
15回または16回試行した後(または変数が「約1分後」である可能性がありますか?)、プログラムがクラッシュします。
更新:あらゆる種類の入力が増えると、プログラムがクラッシュします。私は許可のないユーザーとしてコードをデバッグし、スローされた例外をキャプチャすることができました-どうやらどこからともなく。「コールスタックには外部コードのみが含まれている」と言うのは非常に奇妙で、次のように表示されます。
This thread is stopped with only external code frames on the call stack. External code frames are typically from framework code but can also include other optimized modules which are loaded in the target process.
Call stack with external code
mscorlib.dll!System.Security.Permissions.PrincipalPermission.ThrowSecurityException()
mscorlib.dll!System.Security.Permissions.PrincipalPermission.Demand()
mscorlib.dll!System.Security.PermissionSet.DemandNonCAS()
[Native to Managed Transition]
[Managed to Native Transition]
OHRC Database.exe!OHRC_Database.EmployeeInformationForm.Dispose(Boolean disposing)
System.dll!System.ComponentModel.Component.Finalize()
フォームを閉じるのに苦労していることを意味しているようですか?なぜこの例外がスローされるのか誰かに教えてもらえますか?