Use stored Sql server stored procedure in vc++

Go4Expert Member
30Oct2006,13:29   #1
rajeswaridvssnr's Avatar
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....
Go4Expert Founder
30Oct2006,15:46   #2
shabbir's Avatar
Are you able to execute the same at the Query window of SQL server.
Go4Expert Member
30Oct2006,15:57   #3
rajeswaridvssnr's Avatar
Yes, I am getting the same error when i am doing it in the query window of sql server also.
Go4Expert Founder
30Oct2006,16:01   #4
shabbir's Avatar
Then probably you have some error in connecting to the server domain of the SQL server.
Go4Expert Member
30Oct2006,16:17   #5
rajeswaridvssnr's Avatar
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.
Go4Expert Member
31Oct2006,13:46   #6
rajeswaridvssnr's Avatar
Nobody Is there to help me further???
Go4Expert Founder
31Oct2006,14:46   #7
shabbir's Avatar
Try executing the same SP on some other objects and see whats the output.
Go4Expert Member
31Oct2006,17:08   #8
rajeswaridvssnr's Avatar
I tried the same for different users in my local database as well tried using my remote database also...but the same result
Go4Expert Founder
31Oct2006,18:03   #9
shabbir's Avatar
Then probably the permission issue with the sysadmin role. Check out the permissions of sysadmin.
Go4Expert Member
31Oct2006,18:51   #10
rajeswaridvssnr's Avatar
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.