I would like to grant the MACHINENAME\ASPNET user all acccess to my MSSQL database (i.e tables and stored procedures. I can do this through enterprise manager but id rather do it programatically so i can add it to my database creation script. What is the syntax for this?
I thought it would be along the lines of:
Grant all on databasename to localhost\ASPNET.
But obviously its not! Please help!
thanks
TomIn response to my own question, if anyone needs to know:
exec sp_grantlogin N'machine-name\ASPNET'
goexec sp_grantlogin N'NT AUTHORITY\NETWORK SERVICE'
gouse dbname
goexec sp_grantdbaccess
@.loginame = 'machine-name\ASPNET'
goexec sp_grantdbaccess
@.loginame ='NT AUTHORITY\NETWORK SERVICE'
go
(Rename machinename and dbname to your specifics)
The network service user is required just for windows 2003 i believe, i think on xp and 2000 only ASPNET is needed access.
Tom
No comments:
Post a Comment