p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > SQL Server > SQL Server 2005 > SQL Server 2005
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2009, 09:29 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to executed extended stored procedures as non-sysadmin users????

Hi All,

I have a scenario related to SQL 2005 Security, I have created database "db1" as "sa" user.

Steps followed

1.Created a "dummy" login
2.Created a "dummy" user,mapped to "dummy" login for "db1" database and made database owner.
3.logged in as "dummy" login and created a stored procedure which contains EXEC xp_cmdshell

Statement and while executing the stored procedure, it is throwing below error.

Msg 15153, Level 16, State 1, Procedure xp_cmdshell, Line 1
The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the '##xp_cmdshell_proxy_account##' credential exists and contains valid information.


4. Next, what i done is, i have turned on xp_cmdshell feature and
created a proxy account using Windows Authentication Account.
5. I Again tried to connect to "dummy" login and tried to execute the stored procedure and now it worked.

Now my Question is, what does the below statement do.
EXEC sp_xp_cmdshell_proxy_account 'domain\username', 'domain_user_password'

What affect is there if i created this new account. I know this would create a Proxy Credential but i am wondering how would the "dummy" user can able to utilize this Proxy Account internally because externally/explicitly am not giving/executing any command to make use of this newly created proxy account.

Can anyone please elaborate on how internally this Proxy Account is able to be utilized by the user "dummy" when he is getting logged in.

Am just curious about what is happening internally?

In other words, just want to know how this proxy account is made available to "dummy" user when he is getting logged in.


Commands Used to replicate the scenario.

Step1 : Create the database as "sa" user

use master
go
CREATE DATABASE db1
go

Step2 : Create a login
-- create a login "dummy" as "sa" user
USE [master]
GO
CREATE LOGIN [dummy] WITH PASSWORD=N'dummy', DEFAULT_DATABASE=[db1], CHECK_EXPIRATION=OFF,

CHECK_POLICY=OFF
GO

Step3 : Create a User in "DB1" database and make him database owner.
USE [db1]
GO
CREATE USER [dummy] FOR LOGIN [dummy]
GO
USE [db1]
GO
EXEC sp_addrolemember N'db_owner', N'dummy'
GO

Step4 : login as "dummy" and create a stored procedure which uses xp_cmdshell and when you try to

execute the stored procedure.

It will throw an error.


CREATE PROC USP_TEST
AS
BEGIN
DECLARE @STR VARCHAR(100)
SET @STR = 'GUEST'
PRINT @STR

EXEC sys.xp_cmdshell 'dir c:\*.*'

END

EXEC USP_TEST
/*
GUEST
Msg 15153, Level 16, State 1, Procedure xp_cmdshell, Line 1
The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the

'##xp_cmdshell_proxy_account##' credential exists and contains valid information.

*/

Step5 : Enable the xp_cmdshell feature as "sa" user


EXECUTE sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXECUTE sp_configure 'xp_cmdshell', '1'
RECONFIGURE WITH OVERRIDE
GO
EXECUTE sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

EXEC sys.xp_cmdshell 'dir c:\*.*'



Step6 : Now login as Windows Authentication user and try to create a
proxy account


EXEC sp_xp_cmdshell_proxy_account 'GSPSTRAIL\Administrator', 'mychlocallogin'


Step7: login "dummy" user and again try to execute the stored procedure.
EXEC USP_TEST

Step8: To drop the proxy account, execute the below peice of code.
/*
-- To drop a Proxy Account
-- login as Windows Authentication and execute the below command
/*
EXEC sp_xp_cmdshell_proxy_account NULL
*/


Thanks in Advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extended Stored Procedure. a_boumerhi SQL Server 2000 1 June 4th, 2008 10:23 PM
Stored Procedures help psnow1985 SQL Server 2005 2 April 12th, 2008 02:31 AM
Blocking sysadmin role users...is it possible? Bhalchandra SQL Server 2000 1 November 28th, 2007 06:27 PM
STORED PROCEDURES shazia1 SQL Server ASP 7 September 26th, 2007 07:11 AM
Stored Procedures aadz5 ASP.NET 1.1 4 May 1st, 2004 03:40 AM



All times are GMT -4. The time now is 05:10 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc