更改批处理作业用户身份(运行为) [英] Change batch job user identity (run as)
问题描述
我创建了几个批处理作业以及与之相关的任务,它们运行良好。但是一个问题是,它们首先使用我用来创建作业的帐户运行。我想成为一个系统帐户,而不是我的个人帐户(如果我离开这个地方可能会被停用)
I have created a couple of batch jobs and associated tasks to them, they run fine. But one problem is that they run with the account I have used to create the jobs in the first place. I would like to be a system account instead of my personal account (which could be deactivated if I ever leave this place)
我看不出有任何地方可以更改。
I see nowhere to change this. Do I have to change it via an SQL update statement ?
谢谢。
推荐答案
您可以以所需的任何服务用户身份登录并设置批处理作业,也可以使用 runas(...)
从代码轻松完成此操作( http://msdn.microsoft.com/en-us/library/aa893873。 aspx ):
You can log-in as whatever service user you want and setup the batch jobs, or you can use runas(...)
to do it from code easily (http://msdn.microsoft.com/en-us/library/aa893873.aspx):
server static public void Main(Args _args)
{
RunAsPermission perm;
UserId runAsUser;
SysUserInfo userInfo;
userInfo = SysUserInfo::find();
runAsUser = userInfo.Id;
perm = new RunAsPermission(runAsUser);
perm.assert();
runAs(runAsUser, classnum(EventJobDueDate), "runDueDateEventsForUser");
CodeAccessPermission::revertAssert();
}
这篇关于更改批处理作业用户身份(运行为)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!