2009-05-11 4 views
5

J'ai une application client-serveur assez simple que j'utilise pour séparer deux composants qui ne peuvent pas vivre ensemble dans le même processus. Lors de leur développement (le serveur est un exe, le client est une bibliothèque), tous mes tests unitaires sont heureux comme cochons dans le fumier. Quand je passe à réutilisant la bibliothèque ailleurs, je reçois l'exception suivante:Pourquoi un IpcChannel me dit: "Impossible d'ouvrir un jeton de sécurité de niveau anonyme?"

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. 

J'ai mis en place la communication à distance des deux côtés dans le code, plutôt que de fichiers de configuration pour simplifier à ce stade. Ils sont effectivement identiques:

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

La question est: Pourquoi le cadre de Remoting voudrait créer un jeton anonyme lors de l'usurpation d'identité est activé? Je n'ai plus d'endroits pour chercher des réponses à ce sujet.

Répondre

0

IL EST PAS UNE RÉPONSE

Je sais que c'est une vieille question, mais peut-être quelqu'un a trouvé une solution. J'ai une configuration similaire au niveau de l'identification de l'auteur, mais seulement est requise:

côté serveur:

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

côté 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(); 

Et puis j'obtenir par intermittence ce qui suit: Une erreur s'est produite lors du traitement de la demande sur le serveur: System.Security.SecurityException: Impossible d'ouvrir un jeton de sécurité de niveau anonyme.

à System.Security.Principal.WindowsIdentity.GetCurrentInternal (TokenAccessLevels DesiredAccess, Boolean threadOnly)

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

à System.Runtime.Remoting.Channels .Ipc.IpcServerTransportSink.ServiceRequest (état d'objet)

la zone de l'assemblée qui a échoué était: MyComputer

Questions connexes