Azman returns cached roles to .Net API

Discussion in 'ASP .Net Security' started by Enrique Vargas, Jan 27, 2006.

  1. Hi, I'm using Active Directory as Membership Provider and Azman as
    RoleProvider, everything works fine except that any change made in Azman
    after the ASP.NET 2.0 APP is
    initialized returns a cached version of the roles information. The APP needs
    to know about any change produced while is running. Any idea why Azman is
    returning a cache version of the roles definitions.Thanks.
    Enrique Vargas, Jan 27, 2006
    1. Advertisements

  2. Hi,

    have you tried disabling caching in the roles configuration?
    Dominick Baier [DevelopMentor], Jan 28, 2006
    1. Advertisements

  3. Yes,,

    <roleManager enabled="true" cacheRolesInCookie="false"
    defaultProvider="RoleManagerAzManProvider" cookieRequireSSL="false"
    cookieSlidingExpiration="false" createPersistentCookie="false"
    cookieProtection="All" >
    <add name= xxx />
    Enrique Vargas, Jan 30, 2006
  4. Hi,

    ok - i have to look at the source code then.
    Dominick Baier [DevelopMentor], Jan 30, 2006
  5. Web.Config

    1.Connection Strings.
    <add name="ADConnectionString"
    <add name="AzManConnectionString"

    2.<membership defaultProvider="MyADMembershipProvider">
    <add name="MyADMembershipProvider"
    type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web,
    PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString"
    connectionUsername="domain\Administrator" connectionPassword="pass@word1"
    connectionProtection="Secure" enableSearchMethods="true"
    attributeMapUsername="sAMAccountName" minRequiredPasswordLength="7"
    applicationName="APP" minRequiredNonalphanumericCharacters="1"/>

    3.<roleManager enabled="true" cacheRolesInCookie="false"
    defaultProvider="RoleManagerAzManProvider" cookieTimeout="30"
    cookieRequireSSL="false" cookieSlidingExpiration="false"
    createPersistentCookie="false" cookieProtection="All" >
    <add name="RoleManagerAzManProvider"
    type="System.Web.Security.AuthorizationStoreRoleProvider, System.Web,
    publicKeyToken=b03f5f7f11d50a3a" connectionStringName="AzManADAMServer"

    4.<authentication mode="Forms">
    <forms loginUrl="Login.aspx" defaultUrl="Default.aspx" timeout="30"
    protection="All" requireSSL="false" slidingExpiration="false"

    5. <authorization>
    <deny users="?"/>

    Simple Test Page .aspx.

    If User.Identity.IsAuthenticated Then

    Dim rp As RolePrincipal = CType(User, RolePrincipal)

    Dim roleInfo As StringBuilder = New StringBuilder
    roleInfo.AppendFormat("<h2>Welcome {0}</h2>", rp.Identity.Name)
    roleInfo.AppendFormat("<b>Provider:</b> {0}<BR>",
    roleInfo.AppendFormat("<b>Version:</b> {0}<BR>", rp.Version)
    roleInfo.AppendFormat("<b>Expires at:</b> {0}<BR>",
    roleInfo.AppendFormat("<b>Cache List Changed:</b> {0}<BR>",
    roleInfo.AppendFormat("<b>Is role List Cached:</b> {0}<BR>",
    roleInfo.Append("<b>Roles:</b> ")

    Dim roles() As String = rp.GetRoles

    For i As Integer = 0 To roles.Length - 1
    roleInfo.Append(", ")

    Me.Label1.Text = roleInfo.ToString

    End If
    Enrique Vargas, Jan 30, 2006
  6. Hi,

    does RolePrincipal.SetDirty() help?
    Dominick Baier [DevelopMentor], Jan 30, 2006
  7. Hi,

    aah - you have to set the cacheRefreshInterval attribute in the provider
    config. It is set to 60 (minutes i guess) by default.

    MSDN says

    "Gets the number of minutes between refreshes of the cache of the policy-store

    Dominick Baier [DevelopMentor], Jan 30, 2006
  8. Hi, u are right Dominick the cacheRefreshInterval does the job, thank u!!
    Enrique Vargas, Jan 30, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.