Roles.ApplicationName

Last post 01-09-2007 1:25 AM by Leijun Jie - MSFT. 4 replies.

Sort Posts:

  • Roles.ApplicationName

    01-07-2007, 7:45 PM
    • Participant
      1,110 point Participant
    • cb3431
    • Member since 01-26-2005, 3:27 PM
    • Posts 279

    I have two role providers on my intranet site. I am trying to create a new user for my public facing web site. My intranet site is using Window authentication and my public facing site is using form authentication. Roles for my intranet are handled by azman and my public site is using sql.

    I am trying to add my new user for my public site, but I keep getting the following error.

    It works if I change the defaultProvider to my sql provider.

    The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

    Roles.ApplicationName = "Public"

    Roles.AddUserToRole(

    "user", "Client_Administrator")

     

  • Re: Roles.ApplicationName

    01-08-2007, 4:55 AM
    How does the Roles.ApplicationName effect the issue? As I understand Roles.ApplicationName is used to specify which roles are used by RoleManager based particular ApplicationName. Can you post your membership/roleManager providers from web.config?
    The future is now...
    Sincerely,
    LeiJun Jie
    Microsoft Online Community Support
  • Re: Roles.ApplicationName

    01-08-2007, 7:47 AM
    • Participant
      1,110 point Participant
    • cb3431
    • Member since 01-26-2005, 3:27 PM
    • Posts 279

    <

    roleManager

    enabled="true"

    cacheRolesInCookie="true"

    defaultProvider="IntranetRoles"

    cookieName=".ASPXROLES"

    cookiePath="/"

    cookieTimeout="30"

    cookieRequireSSL="true"

    cookieSlidingExpiration="true"

    createPersistentCookie="false"

    cookieProtection="All">

    <

    providers>

    <

    clear/>

    <

    add

    name="IntranetRoles"

    type="System.Web.Security.AuthorizationStoreRoleProvider"

    connectionStringName="AZConnection"

    applicationName="WebRoles"/>

    <

    add

    name="SqlRoleProvider"

    type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

    connectionStringName="csWeb"

    applicationName="Web"/>

    </

    providers>

    </

    roleManager>

    Doesn't applicationName indicate which provider to use?

  • Re: Roles.ApplicationName

    01-09-2007, 1:13 AM
    Answer
    No, Roles.ApplicationName doesn't indicate which provider is used by roleManager. As I mentioned in my previous post, Roles.ApplicationName is used to fetch roles from aspnet_Roles with specified ApplicationName. You can execute following query in ASPNET database to get an idea how SQL accociates roles with applications:

    select RoleName,ApplicationName
    from aspnet_roles r join aspnet_Applications a
    on r.ApplicationId=a.ApplicationId

    That's similar to Membership.ApplicationName.

    The future is now...
    Sincerely,
    LeiJun Jie
    Microsoft Online Community Support
  • Re: Roles.ApplicationName

    01-09-2007, 1:25 AM
    BTW, your code defines two role providers, and by default the roleManager will always use IntranetRoles provider. If you want to change the provider used by RoleManager, you can take a look at thisĀ MSDN article:

    RoleManagerSection Class
    The future is now...
    Sincerely,
    LeiJun Jie
    Microsoft Online Community Support
Page 1 of 1 (5 items)