Create a feature to test wpDirAuth settings
-
wpDirAuth is working, but I think people who do not know LDAP very well can get really confused. In order to help them, you could add a button to test LDAP authentication.
I had to manually change source code to dump $results variable in
$userDn = @ldap_get_dn($connection, ldap_first_entry($connection, $results))
. If results has one or more items, you can get a wrong userDn if you set an incomplete baseDn in wpDirAuth Settings.Here is my scenario:
- I have RedHat 6.5 with OpenLDAP installed and configured with a CA certificate. - I have WordPress 4.3 and wpDirAuth 1.7.8 - In wpDirAuth settings I had Enable Directory Authentication = YES Require SSL Login = NO Automatically Register Authenticated Users = YES Enable SSL Connectivity = Use SSL (ldaps) Directory Servers (Domain Controllers) = ldapserver.mycompany.com:636 Account Filter = uid Account Suffix = empty/blank BaseDn = "uid=admin,cn=users,cn=accounts,dc=mycompany,dc=com" Bind Password = "my admin user password" Confirm Password = "my admin user password" Authentication Groups = empty/blank Institution Name = "My Company" Marketing name for Institutional Single-Sign-On ID = empty/blank Login Screen Message = A nice message here Password Change Message = Another nice message here Terms of Service Agreement = NO
The only problem above was the BaseDN, which was bringing two records in results array at:
if ( ($results = @ldap_search($connection, $baseDn, $filterQuery, $returnKeys)) !== false ) {
the first record had an invalid DN containing cn=users,cn=compat,dc=mycompany,dc=com. Later, the ldap_first_entry command was picking the first item of results array, that had this incorrect userDN (cn=users,cn=compat,dc=mycompany,dc=com).
Since I cannot test connection and authentication in wpDirAuth to figure what is the correct baseDN setting, I had to include some var_dump inside the source code, which is not really nice.
After debugging it, I figured out that the correct baseDN is
BaseDN = "cn=users,cn=accounts,dc=mycompany,dc=com".
My suggestion is that you wpDirAuth developers add a test button, in order to check if BaseDN, Bind DN and Bind Password are correct.
Another suggestion is to include a field in settings form for redirecting user to a specific URL after a successful authentication.
- The topic ‘Create a feature to test wpDirAuth settings’ is closed to new replies.