Reputation: 3218
I am trying to create a SQL Server Express database using SMO like so:
Database db = new Database(server, dataSource);
...
db.Create();
I am able to use the database fine. But, if someone else tries to copy the database, they get file permission errors. In looking under the security tab in windows explorer, I am the only one who has permission. If I simply make a copy of the file, the copy gives everyone permissions.
So, what do I have to do in order for the Create() to give everyone permission? I would think that the file created would inherit the directory's permissions...but apparently not. I realize I could set the file permissions myself but would rather try to understand why the Create() is giving special permissions.
Upvotes: 0
Views: 1975
Reputation: 754508
I think, you basically only need to add access for the "public" role - never tried it myself, but try this:
Database db = new Database(server, dataSource);
db.Roles.Add(new DatabaseRole(db, "public"));
db.Create();
Does that work? Can your coworkers access the database now?
Marc
Upvotes: 1