简体   繁体   English

授予Windows服务权限以将文件移动到需要的远程目录。 用户/通

[英]Giving Windows Service rights to move files to a remote directory that req. user/pass

I'm using EWS to grab file attachments from emails in an inbox, and need to put those files (if they meet certain criteria) onto a network directory path that requires an active directory user/pass that is not the same as what the machine running the service is using. 我正在使用EWS从收件箱中的电子邮件中获取文件附件,并且需要将这些文件(如果符合某些条件)放到需要活动目录用户/传递的网络目录路径上,该路径与机器不同运行该服务正在使用。

There's probably multiple ways to attack this. 可能有多种方法可以攻击它。 Without having to set that directory path to allow the user/pass that is running the windows service to have rights to read/write is there a way in code that I can set the user/pass before I try and place the files in that path? 无需设置该目录路径以允许运行Windows服务的用户/传递具有读/写权限,代码中有一种方法可以在我尝试将文件放入该路径之前设置用户/传递?

In the installer setup of the windows service I've tried the following: 在Windows服务的安装程序设置中,我尝试了以下内容:

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;
this.serviceProcessInstaller1.Password = "password";
this.serviceProcessInstaller1.Username = @"\\serverName\user";

when I try and install I get an error about mapping the user pass, so I tried this: 当我尝试安装时,我得到一个关于映射用户传递的错误,所以我尝试了这个:

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.NetworkService;
this.serviceProcessInstaller1.Password = "password";
this.serviceProcessInstaller1.Username = @"\\serverName\user";

the installer works, the service shows up and I can start it, but when I debug/attach to the process it throws an exception when trying to write to the directory about access rights. 安装程序工作,服务显示,我可以启动它,但当我调试/附加到进程时,它会尝试写入有关访问权限的目录时抛出异常。

So maybe I'm not even attacking the right issue/section, as this is probably an active directory issue and something not done in code. 所以也许我甚至没有攻击正确的问题/部分,因为这可能是一个活跃的目录问题,而在代码中没有做到。

Any suggestions? 有什么建议么?

What you tried there is irrelevant to your problem. 您在那里尝试的内容与您的问题无关。

If you're on windows 7, you may workaround by going to [Control Panel]->[User Accounts]->[Credential Manager] to store login information of target machines. 如果您使用的是Windows 7,则可以通过转到[控制面板] - > [用户帐户] - > [凭据管理器]来解决目标计算机的登录信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM