Mit dem SQl-Server 2012 wurde eine erweiterte Konfiguration der Skripte eingeführt, die standardmäßig deaktiviert ist.
Befehl zur Anzeige der Konfiguration:
sp_configure
Damit wird die aktuelle Konfiguration im SQL-Server angezeigt. Für die Ausführung eines CMD-Befehls muss der Befehl aktiviert werden. Dieser wird in der Standard-Konfiguration aber nicht angezeigt, weswegen wir die Anzeige erweitern müssen.
Mit den folgenden 4 Befehlen wird die erweiterte Konfiguration eingeschaltet und der Befehl xp_cmdshell aktiviert:
— To allow advanced options to be changed.
EXEC sp_configure ’show advanced options‘, 1
GO
— To update the currently configured value for advanced options.
RECONFIGURE
GO
— To enable the feature.
EXEC sp_configure ‚xp_cmdshell‘, 1
GO
— To update the currently configured value for this feature.
RECONFIGURE
GO
(Quelle: http://msdn.microsoft.com/en-en/library/ms190693.aspx)
Ist ein Benutzer aber nicht Mitglied der festen Serverrolle sysadmin, muss sein Account die Berechtigung ebenfalls erhalten.
— To add the user account to the command
EXEC sp_xp_cmdshell_proxy_account ‚DOMAIN\USERNAME‘, ‚account_password‘;
GO
— To grant the execution
GRANT EXECUTE on xp_cmdshell to [DOMAIN\UserName]
GO
(Quelle: http://copsupport.coplanner.com/help9/index.php/Technik:Microsoft_SQL_Server