Showing posts with label gui. Show all posts
Showing posts with label gui. Show all posts

Wednesday, March 28, 2012

Mapping a user to a login

I have created a login and a user on a database using SMO. I am having trouble mapping a database to the login. When you create a login from the GUI using SQL Server Management Studio Express CTP the user is automatically created and the database is mapped to this login from the user mapping tab. When I create the login programmatically this is not the case so I need to create the user. How do I map the database to the login. I set the default database property on the login but this does not do it.

Thanks,

Michael Gustafson

This is the pattern you would normally follow (this is for a windows user, but it works the same for a SQL user):

Login l = new Login(svr, @."REDMOND\mwories");
l.LoginType = LoginType.WindowsUser;
l.Create();

Database db = svr.Databases["AdventureWorks"];

User u = new User(db, @."REDMOND\mwories");
u.Login = l.Name;
u.UserType = UserType.SqlLogin;
u.Create();

This maps the database user to the login as you create the login.

|||

what property of the Login is used to show what databases are mapped?

also is there a way with SMO to check and see if a password is blank? Granted the odds of that are extemely slimmer with 2005.

|||

I found the DatabaseMapping() class and was able to find which logins were missing mappings. Im still at a lost at how to test for blank passwords using SQL2005 and SMO.

Thanks for taking time to read this.

Chuck Turner

Mapping a user to a login

I have created a login and a user on a database using SMO. I am having trouble mapping a database to the login. When you create a login from the GUI using SQL Server Management Studio Express CTP the user is automatically created and the database is mapped to this login from the user mapping tab. When I create the login programmatically this is not the case so I need to create the user. How do I map the database to the login. I set the default database property on the login but this does not do it.

Thanks,

Michael Gustafson

This is the pattern you would normally follow (this is for a windows user, but it works the same for a SQL user):

Login l = new Login(svr, @."REDMOND\mwories");
l.LoginType = LoginType.WindowsUser;
l.Create();

Database db = svr.Databases["AdventureWorks"];

User u = new User(db, @."REDMOND\mwories");
u.Login = l.Name;
u.UserType = UserType.SqlLogin;
u.Create();

This maps the database user to the login as you create the login.

|||

what property of the Login is used to show what databases are mapped?

also is there a way with SMO to check and see if a password is blank? Granted the odds of that are extemely slimmer with 2005.

|||

I found the DatabaseMapping() class and was able to find which logins were missing mappings. Im still at a lost at how to test for blank passwords using SQL2005 and SMO.

Thanks for taking time to read this.

Chuck Turner

Friday, March 9, 2012

managing XML with a GUI

Perhaps I'm missing something, but I'm going through a cert book for the MCTS 70-431 exam and doing the XML examples. All the examples are in T-SQL -- when I go to find the XML Schemas I've registered I can't seem to find a way to do this in SSMS ... is there a way to graphically manage XML Schema documents in SS05?

I have not done much th the xsl side of things but you can view the registerd collections under the programabilty tab and types for each database.

Managing Triggers

How can I query to see all of the triggers that have been disabled or
enabled' Is there a way to do this using query analyzer or using a gui tool
?
THanks RichardTry,
select
object_name(parent_obj) as table_name,
[name] as trigger_name
from
sysobjects
where
xtype = 'TR'
and objectproperty([id], 'ExecIsTriggerDisabled') = 1
go
AMB
"Richard" wrote:

> How can I query to see all of the triggers that have been disabled or
> enabled' Is there a way to do this using query analyzer or using a gui to
ol?
> THanks Richard