2009-05-11 9 views
5

Aynı işlemde birlikte yaşayamayan iki bileşeni ayırmak için kullanacağım oldukça basit bir istemci-sunucu uygulamasına sahibim. Onları geliştirirken (sunucu bir exe, istemci bir kütüphanedir), tüm birim testlerim gübre olarak domuzlar kadar mutludur. Doğrusu bu aşamada basitlik için yapılandırma dosyalarını daha kodunda her iki tarafta Uzak hizmet kurdunuzBir IpcChannel niçin "Anonim bir güvenlik belirteci açılamıyor?"

System.Runtime.Remoting.RemotingException: An error occurred while processing the request on the server: System.Security.SecurityException: Cannot open an anonymous level security token. 

    at System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess, Boolean threadOnly) 
    at System.Security.Principal.WindowsIdentity.GetCurrent() 
    at System.Runtime.Remoting.Channels.Ipc.IpcServerTransportSink.ServiceRequest(Object state) 
The Zone of the assembly that failed was: 
MyComputer. 

: Başka bir yerde kütüphane kullanan yeniden geçmek, ben şu istisna olsun. Onlar etkili aynıdır:

BinaryClientFormatterSinkProvider client = new BinaryClientFormatterSinkProvider(); 
BinaryServerFormatterSinkProvider server = new BinaryServerFormatterSinkProvider(); 
server.TypeFilterLevel = TypeFilterLevel.Full; 

Hashtable config = new Hashtable(); 
config["name"] = "SomeName"; 
config["portName"] = "SomePortName"; 

config["typeFilterLevel"] = "Full"; 
config["impersonate"] = "true"; 
config["tokenImpersonationLevel"] = "Impersonation"; 
config["useDefaultCredentials"] = "True"; 
config["secure"] = "True"; 

Channel = new IpcChannel(config, client, server); 

Yani soru şu: Neden remoting çerçeve bürünme etkinleştirildiğinde anonim belirteç oluşturmak isteyeyim? Bunun için cevap aramak için yerlerden tamamen tükendim.

cevap

0

BT Ben eski bir soru olduğunu biliyorsun BİR CEVAP

DEĞİL ama belki birisi bir çözüm buldu. Ben yazarın benzer kurulum vardır, ancak yalnızca kimlik seviyesi gereklidir:

Sunucu tarafı:

Dictionary<string, object> properties = new Dictionary<string, object>(); 
properties["authorizedGroup"] = GetUsersGroupName(); 
properties["name"] = configuration.ServiceShortName + ".Server"; 
properties["portName"] = configuration.ServiceGuid; 
BinaryServerFormatterSinkProvider sinkProvider = new BinaryServerFormatterSinkProvider(); 
sinkProvider.TypeFilterLevel = TypeFilterLevel.Full; 
Channel = new IpcServerChannel(properties, sinkProvider); 
Channel.IsSecured = true; 
ChannelServices.RegisterChannel(Channel, true); 
RemotingConfiguration.RegisterWellKnownServiceType(typeof(AppManagerServer), configuration.ServerObjectUrl, WellKnownObjectMode.SingleCall); 

string GetUsersGroupName() 
{ 
     const string builtInUsersGroup = "S-1-5-32-545"; 
SecurityIdentifier sid = new SecurityIdentifier(builtInUsersGroup); 
NTAccount ntAccount = (NTAccount)sid.Translate(typeof(NTAccount)); 
     return ntAccount.Value; 
} 

İstemci tarafı: o zaman

channel = new IpcClientChannel(AppManagerConfiguration.Instance.ServiceShortName + ".Client", null); 
ChannelServices.RegisterChannel(channel, true); 
string appManagerUrl = "ipc://" + AppManagerConfiguration.Instance.ServiceGuid + "/" + AppManagerConfiguration.Instance.ServerObjectUrl; 
(IAppManager)Activator.GetObject(typeof(IAppManager), appManagerUrl).DoSomething(); 

Ve aralıklı aşağıdaki olsun: bir hata sunucudaki isteği işlerken oluştu: System.Security.SecurityException: Anonim bir düzey güvenlik belirteci açılamıyor. System.Runtime.Remoting.Channels de System.Security.Principal.WindowsIdentity.GetCurrent()

de System.Security.Principal.WindowsIdentity.GetCurrentInternal (TokenAccessLevels DesiredAccess, Boole threadOnly)

de

.Ipc.IpcServerTransportSink.ServiceRequest (nesne durumu)

başarısız toplanma bölgesi oldu: MyComputer

İlgili konular