2009-05-11 7 views
5

Ho un'app client-server piuttosto semplice che sto usando per separare due componenti che non possono convivere nello stesso processo. Durante lo sviluppo (il server è un exe, il client è una libreria), tutti i miei test unitari sono felici come suini in letame. Quando mi sposto su di ri-utilizzando la libreria altrove, ottengo la seguente eccezione:Perché un IpcChannel mi dice "Impossibile aprire un token di sicurezza a livello anonimo?"

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. 

Ho installato il servizio remoto su entrambi i lati nel codice, piuttosto che config file per semplicità in questa fase. Essi sono effettivamente identiche:

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

Quindi la domanda è: perché la struttura Remoting vorrebbe creare un token anonimi quando la rappresentazione è attivata? Ho esaurito completamente i posti per cercare risposte su questo.

risposta

0

NON E 'UNA RISPOSTA

Lo so che è una vecchia questione, ma forse qualcuno ha trovato una soluzione. Ho installato simile all'autore di, ma è necessario solo a livello di identificazione:

lato server:

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

lato client:

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

E poi intermittenza ottengo il seguente: un errore si è verificato durante l'elaborazione della richiesta sul server: System.Security.SecurityException: Impossibile aprire un token di sicurezza a livello anonimo.

a System.Security.Principal.WindowsIdentity.GetCurrentInternal (TokenAccessLevels DesiredAccess, booleano threadOnly)

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

a System.Runtime.Remoting.Channels .Ipc.IpcServerTransportSink.ServiceRequest (stato Object)

la Zona del gruppo che non è riuscito era: MyComputer

Problemi correlati