Jaa


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

  1. 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.

  2. Follow the same procedure to set a reference to the following assemblies:

    • Microsoft.Practices.EnterpriseLibrary.Common.dll
    • Microsoft.Practices.ServiceLocation.dll
    • Microsoft.Practices.Unity.dll
    • Microsoft.Practices.Unity.Interception.dll
  3. 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.

  4. (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.

    using Microsoft.Practices.EnterpriseLibrary.Security;
    
    'Usage
    Imports Microsoft.Practices.EnterpriseLibrary.Security