views:

433

answers:

0

I was following this example http://msdn.microsoft.com/en-us/library/ms998331.aspx but seem to be messing something.

I keep getting

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

Line throwing the error:

Line 30: if (Roles.IsUserInRole("TestRole"))

Stack Trace:

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

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
   System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) +337
   System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) +36
   System.Web.Security.AuthorizationStoreRoleProvider.CallMethod(Object objectToCallOn, String methodName, Object[] args) +183
   System.Web.Security.AuthorizationStoreRoleProvider.GetClientContextFromName(String userName) +167
   System.Web.Security.AuthorizationStoreRoleProvider.GetClientContext(String userName) +70
   System.Web.Security.AuthorizationStoreRoleProvider.GetRolesForUserCore(String username) +59
   System.Web.Security.AuthorizationStoreRoleProvider.GetRolesForUser(String username) +72
   System.Web.Security.RolePrincipal.IsInRole(String role) +164
   System.Web.Security.Roles.IsUserInRole(String username, String roleName) +355
   System.Web.Security.Roles.IsUserInRole(String roleName) +19
   _Default.ShowRoleMembership() in c:\projects\adamtest\Default.aspx.cs:30
   _Default.Page_Load(Object sender, EventArgs e) in c:\projects\adamtest\Default.aspx.cs:24
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Role Manager config which I copied from the example

<roleManager
    enabled="true"
    cacheRolesInCookie="true"
    defaultProvider="RoleManagerAzManADAMProvider"
    cookieName=".ASPXROLES"
    cookiePath="/"
    cookieTimeout="30"
    cookieRequireSSL="true"
    cookieSlidingExpiration="true"
    createPersistentCookie="false"
    cookieProtection="All">

    <providers>
        <add name="RoleManagerAzManADAMProvider"
     type="System.Web.Security.AuthorizationStoreRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, 
             publicKeyToken=b03f5f7f11d50a3a"
             connectionStringName="AzManADAMServer"
             applicationName="AzManDemo"/>
      </providers>
    </roleManager>