WCF 服务模拟一个用户但仍然使用 Windows 身份验证?
我正在使用 LinqToEntitiesDomainService
连接到 SQL Server 数据库。这需要 Windows 身份验证,我正在使用它。
我编写了一个 Web 服务,它使用 Activator.CreateInstance(...) 在服务器上运行可执行文件。我也希望使用 Windows 身份验证。 但是,我需要该服务具有运行可执行文件的适当权限。
当我现在运行该服务时,它工作正常。我的帐户具有适当的角色来进行身份验证。我还在服务器上拥有上帝般的权限,这使我可以让 Activator.CreateInstance(...) 命令工作。
虽然具有适当角色的其他用户可以进行身份验证,但他们的帐户在服务器上没有权限,也不应该有权限。
是否有某种(最好是简单的)方法作为一个用户运行该服务,但所有身份验证都通过 Windows 身份验证完成?如果我能在一个应用程序池中完成这一切,那也是最好的...
谢谢!
I am using LinqToEntitiesDomainService
to connect to a SQL Server Database. This requires Windows Authentication, which I have working.
I wrote a web service that uses Activator.CreateInstance(...)
to run an executable on the server. I would like this to use Windows Authentication, as well. However, I need the service to have the proper permissions to run the executable.
When I run the service right now, it works fine. My account has the proper roles to authenticate. I also have god-like permissions on the server, which allows me to have the Activator.CreateInstance(...)
command work.
While other users who have the proper roles can authenticate, their account doesn't have permissions on the server, nor should it.
Is there some (preferably, easy) way to run the service as one user, but have all of the authentication done with windows authentication? It would also be best if I could do it all in just one app pool...
Thank You!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以,请查看这篇文章。这展示了一些模仿用户的技术。
或者在 WCF 中您也可以声明性地定义它。
请注意,这两种技术会模拟客户端(调用者)。
要明确地模拟另一个用户,您需要一些 P/Invoke。这里有一个项目,它非常整洁地为您包装了所有内容。然后你可以这样做:
Yes you can, take a look at this article. This shows some techniques for impersonating users.
Or in WCF you can also define this declaritively.
Note these two techniques impersonate the client (caller).
To impersonate another user explicitly you need some P/Invoke. There's a project here that wraps it all up for you quite neatly. You can then do this: