Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 xp_cmdshell Security Context

Author  Topic 

lmorelli
Starting Member

3 Posts

Posted - 2011-08-10 : 18:04:04
I am launching a utility via stored proc/xp_cmdshell that performs printing functions. It appears that the security context the job runs in does not have access to any printers.

Has anyone worked through this issue? I tried adding the SQL AGENT service to a printer with no luck. Would the context be the same for SQL management studio calling xp_cmdshell in a script window as well as being called from stored procedures in code?

Thanks - Lou

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-10 : 18:21:47
It would be the SQL Server service account and not the Agent account.

This does not sound like a good idea though.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

lmorelli
Starting Member

3 Posts

Posted - 2011-08-10 : 18:49:11
Why not? What solution do you recommend?

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-10 : 19:04:33
I wouldn't recommend doing this at all in SQL Server. SQL Server is not designed for this type of thing. Write an application to handle this printing need, maybe using reporting software even.

Doing this in the stored proc could hang up the calling stored procedure, waiting for it to complete.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

lmorelli
Starting Member

3 Posts

Posted - 2011-08-11 : 00:36:44
The app I call returns instantly, so I'm not concerned about hangs.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-08-11 : 03:05:58
Starting external applications using xp_cmdshell is generally not recommended, but could be justified in some scenarios. You'll have to be aware of the risks though...one being as Tara says; an application hang of some sort. But if this xp_cmdshell is triggered from sql server agent it would be the agent service account that would need printer permissions, otherwise it would be the sql server engine service account.

- Lumbago
My blog-> http://thefirstsql.com/2011/07/08/how-to-find-gaps-in-identity-columns-at-the-speed-of-light/
Go to Top of Page
   

- Advertisement -