Web 服务在远程计算机上执行
我正在使用 asmx Web 服务来锁定远程计算机上的文件夹!
当我在本地计算机上运行 Web 服务时,一切正常,但当我在远程计算机上运行它时,没有任何反应,远程计算机上的文件夹保持解锁状态!
我想我需要在远程计算机上设置此 Web 服务的安全权限,但我不知道在哪里!
那么,我需要什么才能在远程计算机上执行此服务?
I'm using asmx web service to lock a folder on remote computer!
When I run web service on local machine everything working fine, but when I run it on remote computer nothing happen, folder on remote computer stay unlock!
I supose that I need to set security permission for this web service on remote computer, but i don't know where!
So, what I need to enable executing this service on remote computer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我怀疑是权限问题,网络服务是否具有对文件夹的读/写访问权限?
也许你可以尝试身份冒充。
编辑 我首先检查服务器上的文件夹是否具有网络服务的写入权限。如果无法更改文件夹安全性,则使用 Web 配置中的身份模拟并将其映射为服务器上的用户。
编辑2 当代码尝试锁定文件夹时,您是否会抛出任何类型的错误?
I suspect it is permissions, does the network service have read/write access to folder?
Maybe you can try identity impersonate.
EDIT I would begin by checking that the folder on the server has write permissions for the Network Service. If the folder security can not be changed then use the identity impersonate in the web config and map it a user on the server.
EDit 2 Do you get any kind of error thrown when the code tries to lock the folder?
远程 asmx 在什么凭据下运行?它是否有权对自己的文件夹结构之外的文件系统进行操作?
What credentials is the remote asmx running under? Does it have the rights to do operations on the file system outside of its own folder structure?
这是删除用户允许对某些文件夹的权限的函数:
在下一个函数中,我调用RemoveAllowPermission函数:
因此,当我在远程计算机上运行服务时,我的ChangePermission函数捕获异常并返回异常消息错误!
This is the function that remove user allow permission on certain folder:
In next function i call RemoveAllowPermission function:
So when I run service on remote computer my ChangePermission function catch exception and return exception message Error!
由于它是ASMX,我认为它符合ASP.NET的模拟规则。由于没有以编程方式登录的功能,您应该使用非托管 api。
假设您需要在模拟上下文中(在可以访问您想要的位置的远程计算机用户帐户下)执行某些操作。
导入非托管 api:
前面提到的执行可能是这样的:
您不应该忘记撤消模拟并返回到之前的 windowscredentials 状态:
As it is ASMX, I think that it falls for impersonation rules of ASP.NET. As there is no login function programmatically you should use the unmanaged api.
Let's say you need to do something in an impersonation context (under the remote's computer user account that has access at where you want).
Import the unmanaged api:
The aforementioned execute could be something like that:
You should not forget to undo the impersonation and return to the previous windowscredentials state:
好吧,您始终可以像使用管理员帐户一样运行 Web 服务的应用程序池!不建议在生产中这样做,但如果它有效,至少你有一个起点。祝你好运。
Well you could always run the Application Pool of the web service as with an Administrator account! Not advised to do that in production but if it works at least you have a starting point. Good luck.