I am hosting CassiniDev 4.0 in my windows service running an MVC 3.0 configuration site for my service.
I have the web.config setup to use windows authentication. When I look at the HttpContext.User in the web site, it shows the identity that the service is running under, not the itentity of the user making the request. The User.AuthenticationType is NTLM, which is correct, BTW.
This seems pretty clearly to be a bug, but wanted to run it by the community to see if there is some configuration I am missing.
It seems like it might be a variation on this issue postedlast week:
This is definitely a bug in Cassini Dev. It looks like this method is returning the wrong token:
Request.GetUserToken()
. The code:And here _host.GetProcessToken() is a pointer to a security token belonging to the user who owns the Cassini process, it is not the token belonging to the user that's logged in. What needs to happen is the
NtlmAuth
object needs to pass the security token back to theRequest
object so that it can be returned when this method is called instead of the host's token. Not really sure what the best way to do this is but you can see in theNtlmAuth
class, the security token is acquired here:phToken
is the security token but it needs to get back to the Request object and not callInterop.CloseHandle(phToken);
later in that method, where it frees the token. Note that CloseHandle() needs to be called on the token eventually, otherwise a new one will be issued for every request made by a logged in user but unused ones will never get freed. One possible place to do this is in theRequest
object, which subclasses SimpleWorkerRequest and you can override the EndOfRequest method to call CloseHandle() on the security token.