AuthorizationFactory.GetAuthorizationProvider

Topics: Security Application Block
Dec 4, 2008 at 4:07 PM
Edited Dec 4, 2008 at 8:49 PM
I'm still having a problem with the authorization factory in Entlib 4.0

I've looked through this thread and followed the instructions but i'm still getting the same errors.

Config code
  <securityConfiguration defaultAuthorizationInstance="SettlementsProvider"
    defaultSecurityCacheInstance="">
    <authorizationProviders>
      <add storeLocation="msxml://C:\CODE\Settlements v2\Settlements v2\azmanstore.xml"
        application="Settlements" scope="" auditIdentifierPrefix="AzMan Authorization Provider"
        type="Microsoft.Practices.EnterpriseLibrary.Security.AzMan.AzManAuthorizationProvider, Microsoft.Practices.EnterpriseLibrary.Security.AzMan, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        name="SettlementsProvider" />
    </authorizationProviders>
  </securityConfiguration>


            Dim myIdent As WindowsIdentity = WindowsIdentity.GetCurrent()
            Dim principal As IPrincipal = New WindowsPrincipal(myIdent)

            Dim ruleProvider As IAuthorizationProvider = AuthorizationFactory.GetAuthorizationProvider()

            Dim authorized As Boolean = ruleProvider.Authorize(principal, "Privileged Task")
            Return authorized


Still getting the same errors.  Also I've noticed that If I try to add the security block dlls to my wpf projects I get all types of errors.  Does anyone know of any examples that use the security block using active directory? Can't seem to find anything.

Dec 5, 2008 at 5:43 AM
Just need to verify if this is the error you're encountering..
    "Unable to load file or assembly 'Microsoft.Interop.Security.AzRoles, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

I haven't use the Azman Provider yet, but I'm currently trying it out and see if I can repro your error.  I did notice one thing, shouldn't you be using something like this 'msldap://myserver/CN=MyStore,OU=AzMan,DC=MyDomain,DC=Com' as value for the storeLocation property since you're using active directory?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Dec 5, 2008 at 1:27 PM
here is the error that I'm receiving.  I'll try changing the store location

Microsoft.Practices.ObjectBuilder2.BuildFailedException was unhandled
  Message="The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Security.IAuthorizationProvider, AzMan Provider]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.Security.AzMan.AzManAuthorizationProvider, Microsoft.Practices.EnterpriseLibrary.Security.AzMan, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)"
  Source="Microsoft.Practices.ObjectBuilder2"
  ExecutingStrategyIndex=2
  StackTrace:
       at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
       at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
       at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, IConfigurationSource configurationSource)
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource)
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault()
       at Microsoft.Practices.EnterpriseLibrary.Security.AuthorizationFactory.GetAuthorizationProvider()
  InnerException: System.ArgumentException
       Message="The type 'Microsoft.Practices.EnterpriseLibrary.Security.AzMan.AzManAuthorizationProvider, Microsoft.Practices.EnterpriseLibrary.Security.AzMan, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided."
       Source="Microsoft.Practices.EnterpriseLibrary.Common"
       StackTrace:
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.AssemblyQualifiedTypeNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
            at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.NameTypeConfigurationElement.get_Type()
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.CustomProviderAssembler`3.Assemble(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedObjectFactory`2.Create(IBuilderContext context, TConfiguration objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory`2.Create(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.AssemblerBasedCustomFactory`2.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
            at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context)
            at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
       InnerException:

Dec 5, 2008 at 1:56 PM
Are you sure you add the Microsoft.Practices.EnterpriseLibrary.Security.AzMan dll to your project?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com

Dec 5, 2008 at 2:59 PM
Yes I added the dll to my project and registered it in the GAC.  I think the issue may be that I didn't actually create a store in AD.  Instead I created an xml file.  I'm working on getting that first to try and see if that fixes anything.  But isn't it possible to use a an xml file and AD using the Authorization manager?
Dec 5, 2008 at 4:14 PM
Yes it is possible.  I just asked why you're using an xml file when you're asking if anyone had used security block with active directory.  Adding the Microsoft.Practices.EnterpriseLibrary.Security.AzMan.dll to GAC is not necessary.  From what I've read, the Microsoft.Interop.Security.AzRoles is the only one that is required. 


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com