2009-05-11 9 views
5

Mam dość prostą aplikację klient-serwer, której używam do oddzielenia dwóch komponentów, które nie mogą żyć razem w tym samym procesie. Podczas ich tworzenia (serwerem jest exe, klient jest biblioteką), wszystkie moje testy jednostkowe są szczęśliwe jako świnie w odchodach. Kiedy przejść do ponownego korzystania z biblioteki gdzie indziej, otrzymuję następujący wyjątek:Dlaczego IpcChannel mówi mi "Nie można otworzyć tokena bezpieczeństwa anonimowego poziomu?"

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. 

I skonfigurowaniu usług zdalnych po obu stronach w kodzie, zamiast plikach konfiguracyjnych dla uproszczenia na tym etapie. Są one skutecznie identyczne:

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); 

Więc pytanie brzmi: Dlaczego ramy remoting chciałby utworzyć anonimową żeton podczas personifikacji jest włączona? Całkowicie wyczerpałem miejsca, szukając odpowiedzi na ten temat.

Odpowiedz

0

IT nie jest odpowiedź

Wiem, że to stare pytanie, ale może ktoś znalazł rozwiązanie. Mam podobną konfigurację do autora, ale tylko poziom identyfikacja wymagana jest

po stronie serwera:

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; 
} 

po stronie klienta:

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(); 

A potem sporadycznie pojawia się następujący: błąd wystąpił podczas przetwarzania żądania na serwerze: System.Security.SecurityException: Nie można otworzyć tokenu zabezpieczającego poziomu anonimowego.

w System.Security.Principal.WindowsIdentity.GetCurrentInternal (TokenAccessLevels desiredAccess, logiczna threadOnly)

w System.Security.Principal.WindowsIdentity.GetCurrent()

w System.Runtime.Remoting.Channels .Ipc.IpcServerTransportSink.ServiceRequest (stan obiektu)

strefa montażu, że nie udało się: mój_komputer

Powiązane problemy