Hi,
I get a strange problem whereby I have set up a Sql Server Agent job to run as a particular user. The job needs to access details from the users local profile.
The job fails to access the correct user profile when it logs in, and utilises the 'Default User' profile. This happens for scheduled jobs when the actual user used to run the job as is not logged into the machine where the Sql Server instance lives.
If, however, the user IS logged in at the time of job execution, the correct profile is loaded.
I can see this happening by simplying executing an OS command that kicks of a batch file with something like the following:
echo %USERPROFILE%
whoami
When the user is logged in I see the results as expected, eg:
UserProfile = C:\Documents and Settings\myUser
whoami=myDomain\myUser
However when the user is not logged on at the time of execution I get the following:
UserProfile = C:\Documents and Settings\Default User
whoami= myDomain\myUser
Any suggestions would be much appreciated....Its starting to do my head in...
Thanks.
What are associated privileges for that user to run as a SQLAgent account, in general if that job performs any copy or movement within network then the SQLAGent user account must need relevant privileges to complete that task.|||Thanks for the reply..
At this stage the only thing my job is doing is outputing the results of whoami and %USERPROFILE% to a txt file. The job doesn't fail - which I would expect if there was a permissions problem. It just displays the %USERPROFILE% as Default User, when executing via a proxy account (not the SQL Agent Acc) - even though the whoami command shows the correct user is logged in.
Any ideas which privileges need to be applied to both the SQL Agent account, and the account which the proxy maps to?
|||Because of the Proxy usage this is the behaviour, I think. Refer to the books online about SQLAgent operator role
ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/719ce56b-d6b2-414a-88a8-f43b725ebc79.htm
|||The user that I am trying to get the step to log on as is a member of the sysadmin Server Role, so it should have access to all the Sql Server Agent functionality anyway - whether or not it has the SQLAgent operator role assigned..
The thing that has me really confused, is why can the Agent correctly logs the user in to execute the job (ie load the correct profile), ONLY when that same user is currently logged into the machine SQL Server is running on?
Is there maybe some way I could log the user in first, then execute the required step - ensuring that the user is logged out post execution - the thing is though I shouldn't need to do that...aaahhh..
thanks for our help...
No comments:
Post a Comment