Database Reference
In-Depth Information
In this section, we are going to perform the following actions:
Create a new class library containing security authentication code in C#
Upload this library to Analysis Services
Call our stored procedure from MDX to return the Allowed Members set for
Dimension security
The first step thing we need to do in our new C# project is to add a reference to the
msmgdsrv assembly, which gives us access to the Microsoft.AnalysisServices.
AdomdServer namespace. We are not going to explain what everything in this
assembly does; it's enough to say that it allows us to interact with the Analysis
Services server object model in .NET.
In this example, we're going to secure the Sales Territory Country attribute
hierarchy on the Sales Territory dimension. The full code is available with the rest
of the samples for this topic so we won't repeat it here, but the most important part
is the function that returns the set of countries accessible to a user:
public static Set SecuritySet () {
try {
string userName = (new Expression ("UserName ()")
.Calculate (null))
.ToString ();
MemberCollection members = Context.CurrentCube
.Dimensions["Sales Territory"]
.AttributeHierarchies["Sales Territory Country"]
.Levels[1]
.GetMembers ();
SetBuilder sb = new SetBuilder ();
foreach (Member m in members) {
if (RegionsForUsers
.isRegionEnabled (m.Caption, userName)) {
TupleBuilder tb = new TupleBuilder ();
tb.Add (m);
sb.Add (tb.ToTuple ());
}
}
return sb.ToSet ();
} catch (Exception) {
return null;
}
}
 
Search WWH ::




Custom Search