SSAS: Using AMO to Secure Analysis Service Cube (Part-2)
AddMemberToRole()
AddMemberToRole()
·
This is the Role Membership method that adds a windows
user/group to an existing Role.
·
Creates the Role if it does not exist.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
public int AddMemberToRole(String
memberName, String roleName)
{
int retVal
= 1;
bool memberExists
= false;
try
{
//Create role if it does not exist
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null)
{
role = this.Database.Roles.Add(roleName);
this.Database.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
//check role membership already exists for windows
user
foreach (RoleMember member in
role.Members)
{
if (member.Name.Contains(memberName))
memberExists = true;
}
//Add member to role if not already a member
if (!memberExists)
{
role.Members.Add(new
RoleMember(memberName));
role.Update(UpdateOptions.AlterDependents,
UpdateMode.CreateOrReplace);
}
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
AddmemberToRole() failed with out of memory exception. The exception message
is " +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (memberName
== null) { throw new AmoException("ERROR:
memberName parameter supplied with NULL value to AddMemberToRole()"); }
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to AddMemberToRole()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
AddMemberToRole() failed with exception "
+ OpException.Message + ". Parameters passed were
memberName =" +
memberName + ",roleName="
+ roleName);
}
catch (AmoException GenericAmoException)
{
if (memberName.Trim()
== "") { throw new AmoException("ERROR:
memberName parameter supplied with blank value to AddMemberToRole()"); }
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to AddMemberToRole()"); }
throw
GenericAmoException;
}
return
retVal;
}
|
GrantDatabaseRead()
·
Every role created must be given read permission to the Analysis
Service Database. Use this method to grant read access to Analysis Service
Database for a role.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
public int GrantDatabaseRead(String
roleName)
{
int retVal
= 1;
try
{
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null) return -1;
DatabasePermission dbPermission =
this.Database.DatabasePermissions.FindByRole(role.ID);
if (dbPermission
== null)
{
dbPermission = new
DatabasePermission();
dbPermission.RoleID = role.ID;
dbPermission.ID = role.Name;
dbPermission.Name = role.Name;
dbPermission.Read = ReadAccess.Allowed;
this.Database.DatabasePermissions.Add(dbPermission);
}
else
{
dbPermission.Read = ReadAccess.Allowed;
}
dbPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
this.Database.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantCubeRead() failed with out of memory exception. The exception message is
" +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to GrantCubeRead()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantCubeRead() failed with exception "
+ OpException.Message + ". Parameters passed were
roleName=" +
roleName);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to GrantCubeRead()"); }
throw
GenericAmoException;
}
return
retVal;
}
|
Overloaded
GrantDatabaseRead()
·
The overloaded GrantDatabaseRead() method grants read access of
Analysis Service Database for ALL roles.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
public int GrantDatabaseRead()
{
int intRetval
= 1;
try
{
foreach (Role role in
this.Database.Roles)
{
DatabasePermission dbPermission = this.Database.DatabasePermissions.FindByRole(role.ID);
if (dbPermission
== null)
{
dbPermission = new
DatabasePermission();
dbPermission.RoleID = role.ID;
dbPermission.ID = role.Name;
dbPermission.Name = role.Name;
dbPermission.Read = ReadAccess.Allowed;
this.Database.DatabasePermissions.Add(dbPermission);
dbPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
else
{
dbPermission.Read = ReadAccess.Allowed;
}
}
//update database just once (more efficient this way)
this.Database.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantDatabaseReadDefinition() failed with out of memory exception. The
exception message is " + memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch
(OperationException OpException)
{
throw new AmoException("ERROR:
GrantDatabaseReadDefinition() failed with exception " + OpException.Message);
}
catch (AmoException GenericAmoException)
{
throw GenericAmoException;
}
return
intRetval;
}
|
GrantDatabaseReadDefinition()
·
Database Read Definition permission is mostly optional and is
not required for browsing the SSAS cube. Usually required only to examine
Database metadata from SQL Server Management Studio.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
public int GrantDatabaseReadDefinition(String
roleName)
{
int intRetval
= 1;
try
{
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null)
return -1;
DatabasePermission dbPermission =
this.Database.DatabasePermissions.FindByRole(role.ID);
if (dbPermission
== null)
{
dbPermission = new
DatabasePermission();
dbPermission.RoleID = role.ID;
dbPermission.ID = role.Name;
dbPermission.Name = role.Name;
dbPermission.ReadDefinition =
ReadDefinitionAccess.Allowed;
dbPermission.Read = ReadAccess.Allowed;//grant read access
this.Database.DatabasePermissions.Add(dbPermission);
}
else
{
dbPermission.Read = ReadAccess.Allowed;//grant read access
dbPermission.ReadDefinition =
ReadDefinitionAccess.Allowed;
}
dbPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
this.Database.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantDatabaseReadDefinition() failed with out of memory exception. The
exception message is " + memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to GrantDatabaseReadDefinition()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantDatabaseReadDefinition() failed with exception " + OpException.Message + ".
Parameters passed were roleName="
+ roleName);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to
GrantDatabaseReadDefinition()"); }
throw
GenericAmoException;
}
return
intRetval;
}
|
Overloaded
GrantDatabaseReadDefinition()
·
The overloaded GrantDatabaseReadDefinition() method grants read
definition permission of the Analysis Service Database to ALL roles.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
public int GrantDatabaseReadDefinition()
{
int intRetval
= 1;
try
{
foreach (Role role in
this.Database.Roles)
{
DatabasePermission dbPermission =
this.Database.DatabasePermissions.FindByRole(role.ID);
if (dbPermission
== null)
{
dbPermission = new
DatabasePermission();
dbPermission.RoleID = role.ID;
dbPermission.ID = role.Name;
dbPermission.Name = role.Name;
dbPermission.Read = ReadAccess.Allowed;//grant read access
dbPermission.ReadDefinition =
ReadDefinitionAccess.Allowed;
this.Database.DatabasePermissions.Add(dbPermission);
dbPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
else
{
dbPermission.Read = ReadAccess.Allowed;//grant read access
dbPermission.ReadDefinition =
ReadDefinitionAccess.Allowed;
}
}
//update database just once (more efficient this way)
this.Database.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantDatabaseReadDefinition() failed with out of memory exception. The
exception message is " + memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantDatabaseReadDefinition() failed with exception " + OpException.Message);
}
catch (AmoException GenericAmoException)
{
throw GenericAmoException;
}
return intRetval;
}
|
GrantCubeRead()
·
This method grants the role read access to cube.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
public int GrantCubeRead(String
roleName)
{
int retVal
= 1;
try
{
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null) return -1;
CubePermission cubeReadPermission =
this.Cube.CubePermissions.FindByRole(role.ID);
if (cubeReadPermission == null) //no permissions
cubeReadPermission =
this.Cube.CubePermissions.Add(role.ID);
cubeReadPermission.Read = ReadAccess.Allowed;
cubeReadPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantCubeRead() failed with out of memory exception. The exception message is
" +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to GrantCubeRead()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantCubeRead() failed with exception "
+ OpException.Message + ". Parameters passed were
roleName=" +
roleName);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to GrantCubeRead()"); }
throw
GenericAmoException;
}
return
retVal;
}
|
GrantDimensionRead()
·
By default Database Read access implicitly grants read access to
Database Dimensions and Cube Read access implicitly grants access to the Cube
Dimensions. Use this method only if Dimension Data Access is to be defined on
the Dimension’s Attribute.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
public int GrantDimensionRead(String
roleName, String dimensionName)
{
int retVal
= 1;
try
{
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null) return -1;
Dimension dimension =
this.Database.Dimensions.FindByName(dimensionName);
if (dimension
== null) return -1;
DimensionPermission dimReadPermission =
dimension.DimensionPermissions.FindByRole(role.ID);
if (dimReadPermission
== null) //no permission
dimReadPermission =
dimension.DimensionPermissions.Add(role.ID);
dimReadPermission.Read = ReadAccess.Allowed;
dimReadPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantDimensionRead() failed with out of memory exception. The exception
message is " +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to GrantDimensionRead()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantDimensionRead() failed with exception " + OpException.Message + ".
Parameters passed were roleName="
+ roleName);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to GrantDimensionRead()");
}
throw
GenericAmoException;
}
return retVal;
}
|
Overloaded
GrantDimensionRead()
·
Grants read permission on all dimensions in the Analysis Service
Database to the role. This is an expensive operation and time duration to
complete is directly proportional to the number of dimensions and roles in the
Analysis Service Database.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
public int GrantDimensionRead(String
roleName)
{
int retVal
= 1;
try
{
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null) return -1;
foreach
(Dimension dimension in
this.Database.Dimensions)
{
DimensionPermission dimReadPermission =
dimension.DimensionPermissions.FindByRole(role.ID);
if (dimReadPermission == null) //no permission
dimReadPermission =
dimension.DimensionPermissions.Add(role.ID);
dimReadPermission.Read = ReadAccess.Allowed;
dimReadPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantDimensionRead() failed with out of memory exception. The exception
message is " +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to GrantDimensionRead()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantDimensionRead() failed with exception " + OpException.Message + ".
Parameters passed were roleName="
+ roleName);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to GrantDimensionRead()");
}
throw GenericAmoException;
}
return retVal;
}
|
GrantDimensionDataRead()
·
This method defines the Dimension Data Access by securing the
members of the Dimension Attribute using an MDX expression.
·
Test the MDX expression before passing here.
·
Passing an Invalid MDX Expression will not secure the Dimension
Attribute Data and doesn not throw an exception.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
public int GrantDimensionDataRead(string roleName, string dimensionName, string attribName, string mdxExpression)
{
int retVal
= 1;
try
{
Role role = this.Database.Roles.FindByName(roleName);
if (role
== null) return -1;
Dimension dim =
this.Database.Dimensions.FindByName(dimensionName);
if (dim
== null) return -1;
DimensionPermission dimPermission = dim.DimensionPermissions.GetByRole(role.ID);
if (dimPermission == null)
dimPermission = dim.DimensionPermissions.Add(role.ID);
AttributePermission dimAttrPermission =
dimPermission.AttributePermissions.Find(attribName);
if (dimAttrPermission == null)
{
dimAttrPermission = new
AttributePermission();
dimAttrPermission.AllowedSet = mdxExpression;
dimAttrPermission.VisualTotals = "1";
DimensionAttribute dimAttrib =
dim.Attributes.FindByName(attribName);
if (dimAttrib
== null)
return -1;
dimAttrPermission.AttributeID = dimAttrib.ID;
dimPermission.AttributePermissions.Add(dimAttrPermission);
}
else
{
dimAttrPermission.AllowedSet = mdxExpression;
dimAttrPermission.VisualTotals = "1";
dimAttrPermission.AttributeID = attribName;
}
dimPermission.Update(UpdateOptions.AlterDependents,
UpdateMode.UpdateOrCreate);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
GrantDimensionDataRead() failed with out of memory exception. The exception
message is " +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to GrantDimensionDataRead()"); }
if (dimensionName
== null) { throw new AmoException("ERROR:
dimensionName parameter supplied with NULL value to
GrantDimensionDataRead()"); }
if (mdxExpression
== null) { throw new AmoException("ERROR:
mdxExpression parameter supplied with NULL value to
GrantDimensionDataRead()"); }
if (attribName
== null) { throw new AmoException("ERROR:
attribName parameter supplied with NULL value to
GrantDimensionDataRead()"); }
throw
ArgNullException;
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
GrantDimensionDataRead() failed with exception " + OpException.Message + ".
Parameters passed were roleName="
+ roleName + ",dimensionName=" + dimensionName +
",attribName=" + attribName + ",mdxExpression=" + mdxExpression);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "") { throw new AmoException("ERROR:
roleName parameter supplied with blank value to
GrantDimensionDataRead()"); }
If (dimensionName.Trim() == "") { throw new
AmoException("ERROR: dimensionName parameter supplied
with blank value to GrantDimensionDataRead()"); }
if (mdxExpression.Trim()
== "") { throw new AmoException("ERROR:
mdxExpression parameter supplied with blank value to
GrantDimensionDataRead()"); }
if (attribName.Trim()
== "") { throw new AmoException("ERROR:
attribName parameter supplied with blank value to GrantDimensionDataRead()");
}
throw
GenericAmoException;
}
return
retVal;
}
|
DropRole()
·
This method deletes the role from Analysis Service Database. All
permissions associated with the role on Cube, Dimension and Dimension Data will
also be deleted.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
public int DropRole(String
roleName)
{
int retVal
= 1;
Role role = this.Database.Roles.FindByName(roleName);
try
{
if (role
== null)
return retVal;
//delete members from role
if (role.Members.Count
> 0)
{
role.Members.Clear();
role.Update();
}
//delete dimension permissions for the role
foreach (Dimension dim in
this.Database.Dimensions)
{
DimensionPermission dimPermission =
dim.DimensionPermissions.FindByRole(role.ID);
if (dimPermission != null)
{
dimPermission.AttributePermissions.Clear();
dimPermission.Drop(DropOptions.AlterOrDeleteDependents);
}
}
//delete cube permissions for the role
CubePermission cubePermission =
this.Cube.CubePermissions.FindByRole(role.ID);
if (cubePermission
!= null) cubePermission.Drop(DropOptions.AlterOrDeleteDependents);
//delete database permissions for role
DatabasePermission dbPermission =
this.Database.DatabasePermissions.FindByRole(role.ID);
if (dbPermission
!= null) dbPermission.Drop(DropOptions.AlterOrDeleteDependents);
//dbPermission.Update();
//finally delete role from database
role.Drop(DropOptions.AlterOrDeleteDependents);
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
DropRole() failed with out of memory exception. The exception message is
" +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (ArgumentNullException ArgNullException)
{
if (roleName
== null) { throw new AmoException("ERROR: roleName
parameter supplied with NULL value to DropRole()"); }
throw ArgNullException;
}
catch (OperationException OpException)
{
role.Refresh(true);
throw new AmoException("ERROR:
DropRole() failed with exception "
+ OpException.Message + ". Parameters passed were
roleName=" +
roleName);
}
catch (AmoException GenericAmoException)
{
if (roleName.Trim()
== "")
throw new AmoException("ERROR:
roleName parameter supplied with blank value to DropRole()");
throw GenericAmoException;
}
return retVal;
}
|
DropAllRoles()
·
Deletes ALL roles from the Analysis Service Database. All
permissions associated with the role on Cube, Dimension and Dimension Data will
also be deleted.
·
Use this method with care. This is an expensive operation.
·
Throws OutOfMemoryException, ConnectionException,
ArgumentNullException, OperationException and AmoException.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
public int DropAllRoles()
{
int retVal
= 1;
try
{
List<Role> roles = new
List<Role>();
foreach (Role role in
this.Database.Roles)
{
roles.Add(role);
}
foreach (Role role in
roles)
{
this.DropRole(role.Name);
}
}
catch (OutOfMemoryException memoryException)
{
throw new OutOfMemoryException("ERROR:
DropAllRoles() failed with out of memory exception. The exception message is
" +
memoryException.Message);
}
catch (ConnectionException ServerNotFoundException)
{
throw new ConnectionException("ERROR:
Unable to connect to Analysis Server '"
+ this.Server + "'. Connection failed with error
message " +
ServerNotFoundException.Message);
}
catch (OperationException OpException)
{
throw new AmoException("ERROR:
DropAllRoles() failed with exception "
+ OpException.Message);
}
catch (AmoException GenericAmoException)
{
throw GenericAmoException;
}
return
retVal;
}
|
There are few important pointers to watch out for when using
AMO, which I intend to cover in next post. Meanwhile here
are few links related to SSAS cube security.
Related Links:
No comments:
Post a Comment