MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

MonoX Active Directory integration problem  (Mono Support )

Viewed 11157 time(s), 5 post(s) 3/13/2015 7:44:06 AMby pmalara
pmalara

pmalara

3/13/2015 7:55:41 AM
Hi all!
Using the MonoX latest version (MonoX v5.1.40.5107, DB v5.1.40.5027) I'm trying to set up the domain authorization. I followed this tutorial precisely - http://monox.mono-software.com/blog/post/Mono/92/MonoX-Active-Directory-integration/ but I encountered a problem: after entering login and password on login page (and clicking the Log In button) the following exception message appears:

[InvalidCastException: Specified cast is not valid.]
MonoSoftware.MonoX.ModuleGallery.LoginModule.#Gp(Object sender, EventArgs e) +379
System.Web.UI.WebControls.Login.AttemptLogin() +490
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +78
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3586 

Here are the domain integration settings from my web.config:
...
<ActiveDirectoryConfiguration server="dc.domain.local" username="domainuser" password="password" />
...
<add name="ADConnectionString" connectionString="LDAP://dc.domain.local/OU=MONOX-INTEGRATION,DC=domain,DC=local" />
...
    <membership defaultProvider="ActiveDirectoryMembershipProvider" hashAlgorithmType="SHA1">
      <providers>
    <remove name="AspNetSqlMembershipProvider" />
        <add connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="MonoX" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="AspNetSqlMembershipProvider" type="MonoSoftware.MonoX.MonoXMembershipProvider, MonoX" />
        <remove name="ActiveDirectoryMembershipProvider" />
<add name="ActiveDirectoryMembershipProvider" type="MonoSoftware.MonoX.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" applicationName="MonoX"
         connectionUsername="domainuser@domain.local"
         connectionPassword="password" />
      </providers>
    </membership>
...
    <roleManager enabled="true" defaultProvider="ActiveDirectoryRoleProvider">
      <providers>
<remove name="AspNetSqlRoleProvider" />
        <add connectionStringName="LocalSqlServer" applicationName="MonoX" name="AspNetSqlRoleProvider" type="MonoSoftware.MonoX.MonoXRoleProvider, MonoX" />
        <remove name="ActiveDirectoryRoleProvider" />
        <add applicationName="MonoX" name="ActiveDirectoryRoleProvider" type="MonoSoftware.MonoX.ActiveDirectoryRoleProvider" connectionStringName="ADConnectionString"
          groupMode="Additive"
          groupsToUse=""
          groupsToIgnore=""
          usersToIgnore=""
          sqlConnectionStringName="LocalSqlServer"
          cacheTime="0"
          domainName="domain.local"
          userName="domainuser@domain.local"
          password="password"
        />
      </providers>
    </roleManager>


Few more informations:
1) Communication with the Active Directory works ok - there's no authorization errors in log.
2) It seems to that some things work ok - the aspnet_Roles table is filled with domain groups from selected container (OU=MONOX-INTEGRATION).
3) The user also is inserted into the aspnet_Users table.
4) If I switch the membership provider in web.config back to the AspNetSqlMembershipProvider and leave the roleManager with the ActiveDirectoryRoleProvider the MonoX gets the users from SQL DB and roles from domain. This works properly. So I think the problem is somewhere in the ActiveDirectoryMembershipProvider (or code using it).
5) In the OU=MONOX-INTEGRATION I have users and domain groups. Domain groups names match the MonoX roles (e.g. Administrators, Users, etc.)

I even tried to set the IIS pool user to NetworkService, as someone said here (http://monox.mono-software.com/Mono/Pages/Discussion/dtopic/2_ENR6f5okKSmKIbAUmLeg/Active-Directory-Authentication-Integration/) but with no success.

What can I do to make it working? Please help.

Best regards,
Piotr Malara

PS. One more thing: below are the log entries in MonoX log file after each log in try:

2015-03-13 08:28:04,155 [37] ERROR MonoX [::1] - Error
System.InvalidCastException: Specified cast is not valid.
   at MonoSoftware.MonoX.ModuleGallery.LoginModule.#Gp(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Login.AttemptLogin()
   at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
2015-03-13 08:28:04,157 [37] ERROR MonoX [BaseHttpApplication] - Application Error
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidCastException: Specified cast is not valid.
   at MonoSoftware.MonoX.ModuleGallery.LoginModule.#Gp(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Login.AttemptLogin()
   at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
   at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
This content has not been rated yet. 
26 Reputation 3 Total posts
idrazic

idrazic

3/13/2015 3:55:05 PM
Hi pmalara,

I think I know what the issue is.
Unfortunately there's no quick fix.
You'll have to wait for the nightly build next week.

Regards,
Igor
This content has not been rated yet. 
1384 Reputation 152 Total posts
pmalara

pmalara

3/14/2015 11:26:31 AM
Thank you for your answer.

So I'm waiting impatiently for the nightly build.

Best regards,
Piotr
This content has not been rated yet. 
26 Reputation 3 Total posts
idrazic

idrazic

3/19/2015 2:08:17 PM
Please try the v5.1.40.5126 nightly
http://monox.mono-software.com/nightly-build/

Thanks
This content has not been rated yet. 
1384 Reputation 152 Total posts
pmalara

pmalara

4/2/2015 12:34:53 PM
The login proces works properly now. Thanks for the fix.
This content has not been rated yet. 
26 Reputation 3 Total posts