|Microsoft Enterprise Library 5.0|
|Adding Application Code|
The Security Application Block is designed to support the most common scenarios for authorization and caching of security information. When you add your application code, refer to the scenarios in the Key Scenarios section, and select the ones that best match your situation. Use the code that accompanies the scenario as-is or adapt it as necessary.
First, you must prepare your application to use the Security Application Block.
To prepare your application
- Add a reference to the Security Application Block assembly. In Visual Studio, right-click your project node in Solution Explorer, and then click Add References. Click the Browse tab, and then navigate to the location of the Microsoft.Practices.EnterpriseLibrary.Security.dll assembly. Select the assembly, and then click OK to add the reference.
- Follow the same procedure to set a reference to the following assemblies:
- If you intend to use security caching, set a reference to the assembly Microsoft.Practices.EnterpriseLibrary.Security.Cache.CachingStore.dll. You also need to add a reference to the Data Access Application Block assembly, Microsoft.Practices.EnterpriseLibrary.Data.dll, if you are using the Database Cache Storage store in the Caching Application Block.
- (Optional) To use elements from the Security Application Block without fully qualifying the element reference, you can add the using statement (C#) or Imports statement (Visual Basic) to the top of your source code file. The following code shows how to add these statements for the Microsoft.Practices.EnterpriseLibrary.Security namespace.
C# Copy Code
Visual Basic Copy Code