Showing posts with label username. Show all posts
Showing posts with label username. Show all posts

Thursday, March 29, 2012

Granting stored procedure execute permissions from ASP.NET?

Bit of an emergency!
I do not have direct access to our SQL Server but I have full FTP access to the web server and have the db Username/passwords.
I need to grant execute permissions on a stored procedure, can I do this from an asp/ASP.NET page?
The DB guys take 24 hours to run a script against the database!
Any help would be greatfully recieved.
Rich
You can use a SqlCommand object, and set the command text to something like this:
Grant Execute Onsp_name To ASPNET
Then use .ExecuteNonQuery()

Granting db_datareader permissions

Is there a way (Probably a script) to
grant 'db_datareader' permission to a Windows user
(SERVER\username) without the GUI '.
Thanks.You can use sp_addrolemember.
You can find more information on sp_addrolemember in books
online.
-Sue
On Mon, 5 Apr 2004 08:05:51 -0700, "Eric"
<anonymous@.discussions.microsoft.com> wrote:

>Is there a way (Probably a script) to
>grant 'db_datareader' permission to a Windows user
>(SERVER\username) without the GUI '.
>Thanks.|||That is for user defined roles NOT for fixed database
roles.

>--Original Message--
>You can use sp_addrolemember.
>You can find more information on sp_addrolemember in books
>online.
>-Sue
>On Mon, 5 Apr 2004 08:05:51 -0700, "Eric"
><anonymous@.discussions.microsoft.com> wrote:
>
>.
>|||Sorry......My bet. I had a syntax error......

>--Original Message--
>You can use sp_addrolemember.
>You can find more information on sp_addrolemember in books
>online.
>-Sue
>On Mon, 5 Apr 2004 08:05:51 -0700, "Eric"
><anonymous@.discussions.microsoft.com> wrote:
>
>.
>|||No...it's for any existing database role.
-Sue
On Mon, 5 Apr 2004 08:23:27 -0700, "Eric"
<anonymous@.discussions.microsoft.com> wrote:
>That is for user defined roles NOT for fixed database
>roles.
>

Tuesday, March 27, 2012

Granting a user permissions to create and Drop a table

How do I allow a user (or group of users) permission to create/drop a table?

I have found the 'GRANT CREATE TABLE TO username' command, which will (I assume) allow a user to create a table, but how to I allow a user to 'DROP' the created table as well?
'GRANT DROP TABLE TO username' doesn't work?
and I want the users to be able to DROP/DELETE this table (temporary table created just for printing purposes) as well.

thanksWhat I want to know as well is, if the table is DROPPED, do I have to re-set all permissions on it again after it is re-created?
If so, what is the best way to achieve all this/

Thanks|||

See permission section of the DROP TABLE article in BOL. Permissions would have to be reassigned - they are dropped when the table is dropped. You should script all your database operations and manage script files with a source code control product.

Thanks
Laurentiu

Monday, March 26, 2012

Grant Exec to all UDFs and Stored Procedures

Hi All,
I am little at a loss here. I found a procedure that allows me to
pass two parameters: username and dbname and it grants execute to that
user to all stored procedures on theat specific database.
I couldn't find anything that would allow me to grant execute
permissions on all UDFs as well for a specific user.
Is there anything that I can use?
thank you,
T.Same as you do for a stored procedure. you can grant execute permission only
on scalar udfs.
grant execute on <schema.udf_name> to <database_principal>
AMB
"tolcis" wrote:
> Hi All,
> I am little at a loss here. I found a procedure that allows me to
> pass two parameters: username and dbname and it grants execute to that
> user to all stored procedures on theat specific database.
> I couldn't find anything that would allow me to grant execute
> permissions on all UDFs as well for a specific user.
> Is there anything that I can use?
> thank you,
> T.
>

Friday, March 23, 2012

grant access ...

I have created a table with ..

username, password, grant

username and password are nvarchar

grant is a bit

I want to check the availability of the username and password and then check if it is granted to access or not ..

so I made a selection query for getting the grant when username ==x and password = y

x=data come from another page

y=data come from another page

then put the selected grant or deny ( true or false) in a data set ..

and then check if it is grant ( true) to complete what I want >>>

else ( deny ...( false )) to return a reponse of deny username or password...

but everytime the dataset is empty ..

this is my code ...

sqlConnection1.Open();SqlDataAdapter da=new SqlDataAdapter("select grant_deny from users where username='"+Request.QueryString["username"]+"' and password='"+Request.QueryString["password"]+"'",sqlConnection1);da.Fill(ds,"users");sqlConnection1.Close()if (ds.Tables[0].Rows[0]["grant_deny"].ToString()=="true"){ . . . . }else { Response.write("error"); }

what is wrong ..??

and if there is anyone has another solution for what I want .. I appriciate any sample code,...

thanks in advance..

Hi,

Make sure you are providing the correct username and password in your sql query. Also, QueryStrings are not safe to pass sensitive informations like passwords.

Regards

Wednesday, March 21, 2012

Grand Total of an iif expression

I have a report grouped on the user. The report calculates various
utilization totals based on the username. Some users have a Utilization = 100% for only 12 or 17 hours and other have a Utilization = 100% for 40
hours. At the group level, I can calculate the utilization with the
following formula...
=iif ( Fields!zUserID.Value ="USER1 ",
(Sum( Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
Fields!zQtyBilled.Value , "GroupUserName")) / 12 ,
iif ( Fields!zUserID.Value ="USER2 ", (Sum(
Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
Fields!zQtyBilled.Value , "GroupUserName")) / 17 , (Sum(
Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
Fields!zQtyBilled.Value , "GroupUserName")) / 40 ))
However, my issue is how do I get a grand total of this utilization on the
report footer. I cannot sum () this formula in the report footer. I receive
an error becuase of the "GroupUserName" parameter.
Is there a way to use the sum () function in the Report Footer and just
reference the name of the textbox in the group footer and it's corresponding
value that has already been calculated for each group?I probably do not understand your question very well, but you might try to
simply do the sum without regard to the groupings ( simply take out the
groups) and do the sum for the entire data set...
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"Jack Bender" wrote:
> I have a report grouped on the user. The report calculates various
> utilization totals based on the username. Some users have a Utilization => 100% for only 12 or 17 hours and other have a Utilization = 100% for 40
> hours. At the group level, I can calculate the utilization with the
> following formula...
> =iif ( Fields!zUserID.Value ="USER1 ",
> (Sum( Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
> Fields!zQtyBilled.Value , "GroupUserName")) / 12 ,
> iif ( Fields!zUserID.Value ="USER2 ", (Sum(
> Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
> Fields!zQtyBilled.Value , "GroupUserName")) / 17 , (Sum(
> Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
> Fields!zQtyBilled.Value , "GroupUserName")) / 40 ))
> However, my issue is how do I get a grand total of this utilization on the
> report footer. I cannot sum () this formula in the report footer. I receive
> an error becuase of the "GroupUserName" parameter.
> Is there a way to use the sum () function in the Report Footer and just
> reference the name of the textbox in the group footer and it's corresponding
> value that has already been calculated for each group?
>|||The issue here is that I need a conditional total and percentage calculation
based on the users that billed time in the report. If User 1 and/or User 2
are in the report, then they have different criterias for utilization
calcualtons than everyone else. All other users are based on 40 hours a
week. I determine this already at the group footer, so it would be much
easier just to grand total the cell value of the group footer then to
re-engineer the formula for the report footer.
"Wayne Snyder" wrote:
> I probably do not understand your question very well, but you might try to
> simply do the sum without regard to the groupings ( simply take out the
> groups) and do the sum for the entire data set...
> --
> Wayne Snyder MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> I support the Professional Association for SQL Server ( PASS) and it''s
> community of SQL Professionals.
>
> "Jack Bender" wrote:
> > I have a report grouped on the user. The report calculates various
> > utilization totals based on the username. Some users have a Utilization => > 100% for only 12 or 17 hours and other have a Utilization = 100% for 40
> > hours. At the group level, I can calculate the utilization with the
> > following formula...
> >
> > =iif ( Fields!zUserID.Value ="USER1 ",
> > (Sum( Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
> > Fields!zQtyBilled.Value , "GroupUserName")) / 12 ,
> >
> > iif ( Fields!zUserID.Value ="USER2 ", (Sum(
> > Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
> > Fields!zQtyBilled.Value , "GroupUserName")) / 17 , (Sum(
> > Fields!zBillingWorkQty.Value , "GroupUserName") + Sum(
> > Fields!zQtyBilled.Value , "GroupUserName")) / 40 ))
> >
> > However, my issue is how do I get a grand total of this utilization on the
> > report footer. I cannot sum () this formula in the report footer. I receive
> > an error becuase of the "GroupUserName" parameter.
> >
> > Is there a way to use the sum () function in the Report Footer and just
> > reference the name of the textbox in the group footer and it's corresponding
> > value that has already been calculated for each group?
> >
> >