Thread.CurrentPrincipal에 대한 주 스레드에서 워크 플로 응용 프로그램으로 전파되지 않는 문제가 있습니다.Windows 워크 플로 및 Thread.CurrentPrincipal
어쨌든 이것을 할 수 있습니까?
class Program
{
static void Main(string[] args)
{
Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("Bob", "Passport"), new string[] { "managers", "executives" });
System.Console.WriteLine("MainThread Prinicipal type: " + Thread.CurrentPrincipal.GetType().ToString());
System.Console.WriteLine("MainThread Prinicipal Identity: " + Thread.CurrentPrincipal.Identity.Name);
System.Console.WriteLine();
AutoResetEvent syncEvent = new AutoResetEvent(false);
WorkflowApplication application = new WorkflowApplication(new Workflow1());
application.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
syncEvent.Set();
};
application.Run();
syncEvent.WaitOne();
}
}
워크 플로
<Activity mc:Ignorable="sap" x:Class="WorkflowConsoleApplication1.Workflow1" sap:VirtualizedContainerService.HintSize="273,427" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:s4="clr-namespace:System;assembly=System.ServiceModel" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Threading;assembly=System.Core" xmlns:st1="clr-namespace:System.Threading;assembly=System" xmlns:st2="clr-namespace:System.Text;assembly=mscorlib" xmlns:st3="clr-namespace:System.Threading;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Sequence sad:XamlDebuggerXmlReader.FileName="C:\projects\WorkflowConsoleApplication1\WorkflowConsoleApplication1\Workflow1.xaml" sap:VirtualizedContainerService.HintSize="233,387">
<WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="["WorkflowThread Prinicipal type: " + System.Threading.Thread.CurrentPrincipal.GetType().ToString()]" />
<WriteLine sap:VirtualizedContainerService.HintSize="211,61" Text="["WorkflowThread Prinicipal Identity: " + System.Threading.Thread.CurrentPrincipal.Identity.Name]" />
<WriteLine sap:VirtualizedContainerService.HintSize="211,61" />
</Sequence>
</Activity>
상기 프로그램으로부터의 출력은 :
MainThread Prinicipal 유형 : System.Security.Principal 여기
내 샘플 애플리케이션 인 .GenericPrincipal
MainThread 주체 신원 : BobWorkflowThread Prinicipal 유형 : System.Security.Principal.GenericPrincipal
WorkflowThread Prinicipal 정체성 : 어떤 도움이 크게 감사합니다
.
당신에게
젠장, [workflow-foundation-4] rss 피드도보고 있습니까? – Will
Yup :-) 이제 코멘트의 길이가 최소가되어야하는 이유는 무엇입니까? – Maurice
그것의 성가신,하지만 만약 당신이 [이 사용자 스크립트 (http://stackapps.com/questions/2051/reply-links-on-comments) 그것을 얻을 수 있도록 쉽게 길이가 짧은 주석 (삽입 @ 사용자 이름 :에서 코멘트의 시작) (편집 : @maurice fixed link) – Will