Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 403
  • Last Modified:

Executing DDL statements as non privileged user

Any ideas on how to execute DDL statements as a non-sysadmin user.  I prefer not to use osql because it would require username and password in a stored procedure which is granted execute permissions to the non-sysadmin users.  I would like to use Windows authentication as much as possible.

I found this solution http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_10212489.html?query=assigning+sql+server+ddl+permissions&clearTAFilter=true but I really do not want to use SQL server users.
0
optimacommunications
Asked:
optimacommunications
  • 5
  • 4
  • 2
1 Solution
 
rw3adminCommented:
you will have to create a new user who has db_admin rights on that database and run these DDLs as that, thats simple ... so maybe I am not understanding your question clearly
0
 
optimacommunicationsAuthor Commented:
I would like to use some type of proxy/chaining to facilitate the user rather than give them powerful ddl_admins rights.  I do not want to use OSQL to run an sql command as a privileged user.
0
 
rw3adminCommented:
ok, we do use windows authentication for lot of that, you would basically be creating user in Active Directory and then adding them back in SQL Enterprise Manager>>Security>>Logins this is where you will define this login's role to db_ddladmin and nothing else.
one more thing though you would wanna make sure you still create objects as "create table dbo.tablename" instead of just "create table tablename"

rw3admin
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
optimacommunicationsAuthor Commented:
I do not want the user to be a member of the ddladmin role!  I need users to create and drop permanent tables when they access a report.  These actions will be transparent to them.  If I permit them as members of admin, this will give them too much power and potentially unnecessary grief for me.

Let me try to explain the scenario a bit more: developers create reports in excel.  I do not want SQL login connection strings in the excel sheets so they now use Windows authentication. The users of the excel sheets (windows users), will run stored procedures which have DDL statements embedded.  Non ddladmins are unable to run ddl statements so I want a work around that will enable the users to run the statements but still have little or no priviliges outside of the stored procedure permissions assigned to them.

I hope this clarifies stuff a bit more.  It is certainly more tricky that it appears.
0
 
rw3adminCommented:
yes that clears the confusion, thanks
I hope users have data write access, if yes then since regular users dont have access to DDL, you can insert this DDL command in a table now create a job as db_admin on the server that check this table and execute DDL commands out of that every 30 seconds or so, the tricky part around programming would be to return handle back to the proc containing this DDL statement


 
0
 
optimacommunicationsAuthor Commented:
Hmm ... this is turning out to be more messy than I imagined!!!  I will keep looking and see if we can come up with a simpler solution.
0
 
rw3adminCommented:
:)
sorry for my messy design, I am actually doing something like that right now, I dont want support to be able to start and stop jobs without checking if its going to effect other jobs and server activity, so I wrote them a interface where they come and schedule job to run as soon as its "OK" to run them, this insert the user_id, request and date in database they dont have any access to it.
Now I created a job on that server which runs every minute and check this table for any new request and will only run it after checking against some conditions/rules that I have defined in another table.
This way my life is much easier I dont get into server lock issues, niether client calls and yell and everyone is happy

rw3admin
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>I need users to create and drop permanent tables when they access a report.
why do the tables need to be dropped and recreated?
would a truncate or simply a global temp table not be better suited?


otherways, unless you can create the tables in advance, you have to do like rw3admin indicates, although I would put a insert trigger in the table he mentionned to the job would start immediately... anyhow, there would be no easy way out.
0
 
optimacommunicationsAuthor Commented:
The tables need to be permanent because the structure may change and they need to be available for later retrieval.  I guess there is no easy way out which confirms my worst fears!

I guess this is a dead end issue which can be closed by the moderator.  Guys, thank you for your thoughts.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>I prefer not to use osql because it would require username and password in a stored procedure which is granted execute permissions to the non-sysadmin users.
let me come back to this.
actually, if sql server runs as a (dedicated) domain user, and that domain user has login permissions (ie the required DDL permissions), you can use the -E flag of osql to connect with windows authentication.
0
 
optimacommunicationsAuthor Commented:
Geez ... simple solution!! Thank you.  All the time, I thought -E was for the currently logged in user rather than the SQL Server account!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now