Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Use stored Sql server stored procedure in vc++ (http://www.go4expert.com/forums/stored-sql-server-stored-procedure-vcpp-t1754/)

rajeswaridvssnr 30Oct2006 13:29

Use stored Sql server stored procedure in vc++
 
My question is How to lock a user account in sql server.
I am calling the following stored procedure in my vc code.....

/* Lock user */
IF @p_commit = 'Y' BEGIN
EXEC sp_denylogin @p_operid
END

This is to lock a user account created in sql server but i am getting the following error....

'Work' is not a Valid Window NT name. Give the complete name: <domain\username>. Here 'work' is one of the PI operators with sql server authentication.

The same type of error i am getting when trying to unlock user using EXEC sp_grantlogin...
What should i use in my stored procedure to lock or unlock my sqlserver user...

Here work is one of the sql server users available with me ......

I don't want to restrict the winnt user...i want to restrict only sql server user to login to my application using sqlserver.

Any suggetions are Welcome..........Thanks InAdvance.... :)

shabbir 30Oct2006 15:46

Re: Use stored Sql server stored procedure in vc++
 
Are you able to execute the same at the Query window of SQL server.

rajeswaridvssnr 30Oct2006 15:57

Re: Use stored Sql server stored procedure in vc++
 
Yes, I am getting the same error when i am doing it in the query window of sql server also.

shabbir 30Oct2006 16:01

Re: Use stored Sql server stored procedure in vc++
 
Then probably you have some error in connecting to the server domain of the SQL server.

rajeswaridvssnr 30Oct2006 16:17

Re: Use stored Sql server stored procedure in vc++
 
No, I am able to connect to the sql server with those users.
I have one user who has sysadmin role. I do login to the sqlserver using that user.
I am trying to lock/Unlock other sqlserver users by using sp_grantlogin and sp_denylogin

EXEC sp_denylogin 'work'

but i am getting the following error

'Work' is not a Valid Window NT name. Give the complete name: <domain\username>. Here 'work' is one of the users with sql server authentication.

rajeswaridvssnr 31Oct2006 13:46

Re: Use stored Sql server stored procedure in vc++
 
Nobody Is there to help me further???

shabbir 31Oct2006 14:46

Re: Use stored Sql server stored procedure in vc++
 
Try executing the same SP on some other objects and see whats the output.

rajeswaridvssnr 31Oct2006 17:08

Re: Use stored Sql server stored procedure in vc++
 
I tried the same for different users in my local database as well tried using my remote database also...but the same result

shabbir 31Oct2006 18:03

Re: Use stored Sql server stored procedure in vc++
 
Then probably the permission issue with the sysadmin role. Check out the permissions of sysadmin.

rajeswaridvssnr 31Oct2006 18:51

Re: Use stored Sql server stored procedure in vc++
 
sysadmin permission to my user is looking fine. some of my findings are like this. Sql server provides 2 types of authentication to the users.
1) windows authentication with the domain name
2) sql server authentication.

My user is having only sql server authentication.Because we need to work with the remote databases.

so here what i want is I need to lock the access permission to one of my user not having sysadmin role.

I think sp_grantlogin and sp_denylogin will work only for the windows authentication mode users.
So how to lock my user having sqlserver authentication.

Hope you got my point.


All times are GMT +5.5. The time now is 05:23.