dbTalk Databases Forums  

DSO and SetPermissions

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss DSO and SetPermissions in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Paul
 
Posts: n/a

Default DSO and SetPermissions - 09-22-2005 , 07:36 AM






Hi,

I am trying to create a Role and set it's permissions using...

Dim dsoServer As DSO.Server
Dim dsoDatabase As DSO.Database
Dim DbRole As DSO.Role

Set dsoServer = New DSO.Server
dsoServer.Connect ("LocalHost")

Set dsoDatabase = dsoServer.MDStores("FoodMart 2000")
Set DbRole = dsoDatabase.Roles.AddNew("ReadOnlyRole")

DbRole.UsersList = "Everyone"

'This just won't accept the 'Access' Argument!!!
DbRole.SetPermissions "Access", "RW"

DbRole.Update

....
But the line of code just above here comes back as 'Invalid Role Permission
key' even though I copied this out of help!

Any ideas?
Ta
Paul

Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: DSO and SetPermissions - 09-25-2005 , 11:34 PM






Setting Roles in DSO can be a little bit painful, the basic steps are as
follows.

1. Create a database role and assign users/groups and do a .update on
that role.

2. Add a cube role with the SAME NAME as the database role. Set the
individual cube permissions here. If the role needs access to more than
one cube you will need to add it to each cube individually. Call .update
on the Cube object to save the changes.

I have included some sample code below. You can get a lot more involved
with the permissions, setting dimension security, but you have to use
the permissions XML string to do this.

'==================================

Dim dsoServer As DSO.Server
Dim dsoDb As DSO.Database
Dim dbRole As DSO.Role
Dim cubeRole As DSO.Role
Dim dsoCube As DSO.Cube

'\\ Connect to Server
Set dsoServer = New DSO.Server
dsoServer.Connect "DARREN01"

'\\ Connect to database
Set dsoDb = dsoServer.MDStores("Foodmart 2000")

'\\ Add a new Database Role and update it
Set dbRole = dsoDb.Roles.AddNew("TestRole")
dbRole.UsersList = "Everyone"
dbRole.Update

'\\ Get a reference to a cube
Set dsoCube = dsoDb.MDStores("Sales")

'\\ Add a cube role - linked to database role by using the same Name
Set cubeRole = dsoCube.Roles.AddNew("TestRole")
cubeRole.SetPermissions "Access", "RW"

'\\ Update the Cube to save the cube role
dsoCube.Update
dsoDb.Update

'\\ Close the server and de-reference variables
dsoServer.CloseServer

Set dsoCube = Nothing
Set dsoDb = Nothing
Set dbRole = Nothing
Set cubeRole = Nothing
Set dsoServer = Nothing

'=====================================

--
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell

Reply With Quote
  #3  
Old   
Paul
 
Posts: n/a

Default Re: DSO and SetPermissions - 10-02-2005 , 02:13 PM



That's great - thanks!

"Darren Gosbell" wrote:

Quote:
Setting Roles in DSO can be a little bit painful, the basic steps are as
follows.

1. Create a database role and assign users/groups and do a .update on
that role.

2. Add a cube role with the SAME NAME as the database role. Set the
individual cube permissions here. If the role needs access to more than
one cube you will need to add it to each cube individually. Call .update
on the Cube object to save the changes.

I have included some sample code below. You can get a lot more involved
with the permissions, setting dimension security, but you have to use
the permissions XML string to do this.

'==================================

Dim dsoServer As DSO.Server
Dim dsoDb As DSO.Database
Dim dbRole As DSO.Role
Dim cubeRole As DSO.Role
Dim dsoCube As DSO.Cube

'\\ Connect to Server
Set dsoServer = New DSO.Server
dsoServer.Connect "DARREN01"

'\\ Connect to database
Set dsoDb = dsoServer.MDStores("Foodmart 2000")

'\\ Add a new Database Role and update it
Set dbRole = dsoDb.Roles.AddNew("TestRole")
dbRole.UsersList = "Everyone"
dbRole.Update

'\\ Get a reference to a cube
Set dsoCube = dsoDb.MDStores("Sales")

'\\ Add a cube role - linked to database role by using the same Name
Set cubeRole = dsoCube.Roles.AddNew("TestRole")
cubeRole.SetPermissions "Access", "RW"

'\\ Update the Cube to save the cube role
dsoCube.Update
dsoDb.Update

'\\ Close the server and de-reference variables
dsoServer.CloseServer

Set dsoCube = Nothing
Set dsoDb = Nothing
Set dbRole = Nothing
Set cubeRole = Nothing
Set dsoServer = Nothing

'=====================================

--
Regards
Darren Gosbell [MCSD]
dgosbell_at_yahoo_dot_com
Blog: http://www.geekswithblogs.net/darrengosbell


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.