I need to create a new login in SQL Server 2005 using SMO.
I create the new login using this code :
ServerConnection connection = new Microsoft.SqlServer.Management.Common.ServerConnection(Server, Server_UserName, Server_Password);
Microsoft.SqlServer.Management.Smo.Server sqlServer = new Microsoft.SqlServer.Management.Smo.Server(connection);
// Creating Login
Login login = new Login(sqlServer, "loginName");
login.LoginType = LoginType.SqlLogin;
login.Create("loginPassword");
login.AddToRole("sysadmin");
login.AddToRole("serveradmin");
and now I need that all the databases in the user mapping tab (in SQL Server Management Studio) will be checked….
How do I do it in SMO?
Mapping a user to all DataBases :