diff --git a/credits.txt b/credits.txt
index 47d6916..0bf6fba 100644
--- a/credits.txt
+++ b/credits.txt
@@ -1,18 +1,18 @@
=== wpDirAuth Credits ===
wpDirAuth is made possible by the following contributors:
-
+
+ Stephane Daury
+ Current maintainer
+ Montreal, QC, Canada
+ http://stephane.daury.org/
+
Paul Gilzow
Current maintainer
Columbia, MO, USA
http://profiles.wordpress.org/users/gilzow/
-
- Stephane Daury
- Original author
- Montreal, QC, Canada
- http://stephane.daury.org/
- Todd Beverly
+ Todd Beverly
wpDirAuth QA and patch contributor
Rochester, NY, USA
See http://wordpress.org/support/topic/129814
diff --git a/readme.txt b/readme.txt
index 95d8b13..8d1933e 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,229 +1,175 @@
-=== wpDirAuth ===
-Contributors: gilzow, stephdau, apokalyptik
-Tags: login, authentication, directory, ldap, ldaps
-Requires at least: 2.2
-Tested up to: 3.4.2
-Stable tag: 1.7.6
-
-WordPress directory authentication plugin through LDAP and LDAPS (SSL).
-
-== Description ==
-
-See
-
-PLEASE NOTE
-Beta testers of the 1.7.X branch prior to version 1.7.5, you will need to
-deactivate wpdirauth before you updgrade to this latest version. Once you
-have installed and network activated the plugin, it will copy your options
-from their previous location to the sitemeta table. You will only need to
-do this once. This will also work for anyone who was using the 1.6.X
-branch or older and plans on using it in MULTISITE mode.
-
-Version 1.7.5 brings full MULTISITE support.
-
-wpDirAuth allows users of central directory (LDAP) servers to login to
-authorized WordPress instances without having to register. The plugin creates
-a new account for each directory user on first login so that they have full
-access to preferences and functions, as any WP user would.
-
-Activating the plugin will not restrict you to using directory authentication
-and you will still be able to both create new WP-only users as well as turn on
-public registration in WordPress. You can also assign any privilege levels to
-your directory users, and the those users will be referred to their
-institutional password policy whenever they would normally able to update
-their WP passwords (on the profile screen, in user edit, etc).
-
-= LDAP/LDAPS =
-
-Authentication should work with most LDAP enabled directory services, such as
-OpenLDAP, Apache Directory, Microsoft Active Directory, Novell eDirectory,
-Sun Java System Directory Server, and more.
-
-wpDirAuth supports LDAP and LDAPS (SSL) connectivity and can force SSL for
-WordPress authentication if it is available on the Web server. It also supports
-server connection pools, for pseudo load balancing and fault tolerance, or
-multiple source directory authentication.
-
-Because the key used to locate a user's profile in the LDAP server is not
-always the same, depending on your LDAP server type and institutional choices,
-you can define your own through the wpDirAuth administration tool.
-
-When logging in as a directory user, the WP "remember me" feature is downgraded
-from 6 months for regular WP users to only 1 hour, so that institutional
-passwords are not overly endangered when accessing WP from public terminals.
-
-= Branding & Notifications =
-
-You can define notifications addressed to your directory users in key WordPress
-areas, such as the login screen and the profile edit screen.
-
-Since these admin-editable values support HTML (admin, coders, beware of xss!),
-you can point your directory users to central support information related to
-functions such as changing their institutional password, a WordPress usage
-related policy, etc.
-
-There is also a simple and optional terms of services concept, only implemented
-for directory users, which will simply record a one-time acceptance date when
-agreed upon. Note that agreeing to the TOS has no effect on the user's level of
-access in the system, fact which could change in future version if there is a
-demand for it, or through direct code contribution to that effect.
-
-
-== Download ==
-
-You can download the latest stable version of wpDirAuth from the WordPress
-Plugin Finder at the following locations:
-
-* Direct download:
-* WPPF home:
-
-
-== Installation ==
-
-Installing should be a piece of cake and take fewer than ten minutes, provided
-you know your directory server(s) information, and that your blog is allowed to
-connect and bind to it/them.
-
-Please refer to your friendly neighbourhood LDAP sysadmin for more information.
-
-1. Upload the `wpDirAuth` directory to the `/wp-content/plugins/` directory.
-1. Login to your WordPress instance as an admin user.
-1. Activate the plugin through the 'Plugins' menu in WordPress.
-1. Go to the `Directory Auth.` menu found in the WordPress `Options` section.
-1. Enter your directory server(s) information and set your preferences.
-
-You should now be able to login as a directory user.
-
-
-== Using wpDirAuth ==
-
-Once installed and activated, you will be able to administer your directory
-settings through the dedicated plugin configuration tool found under the
-`Directory Auth.` menu found in the WordPress `Options` admin section.
-
-Directory Authenticated users can now be pre-added to your wordpress system
-and granted roles by going to the `Add Dir Auth User` menu found in the
-Wordpress `Users` admin section. Contextual help for this section is
-available for this section within Wordpress' built-in help menu.
-
-See the inline help found in the tool for more information on the settings.
-
-There is a secondary activation toggle, so you can install and activate the
-plugin, check out the options panel, but not immediately accept directory
-authentication, or even simply turn the feature on or off at any time.
-
-
-== Help and Support ==
-
-Please post questions, request for help to the Wordpress plugins forum or
-email . Please be sure to include 'wpdirauth' in the
-subject line.
-
-== TO-DO's ==
-
-
-== Source and Development ==
-
-wpDirAuth welcomes friendly contributors wanting to lend a hand, be it in
-the form of code through SVN patches, user support, platform portability
-testing, security consulting, localization help, etc.
-
-The [current] goal is to keep the plugin self-contained (ie: no 3rd-party lib)
-for easier security maintenance, while keeping the code clean and extensible.
-
-Focus is on security, features, security, and let's not forget, security.
-Unit tests will hopefully be developed and constant security audit performed.
-
-Recurring quality patch contributions will lead to commit privileges to the
-project source repository.
-
-Please post questions/requests for help to the wordpress forums and/or
-email
-
-The project source code is available on the WordPress Plugin Repository:
-
-* Stable:
-* Unstable:
-* Historical:
-
-The Sybversion repository can be browsed and tracked (RSS, etc) through the
-WP Plugin Repo source browser at:
-
-*
-
-The generated code documentation can be found at:
-
-*
-
-The WP Plugin Repo also offers a convenient ticketing system for bug and
-task tracking.
-
-* Existing tickets:
-* Open a new ticket:
-
-
-== License ==
-
-[General Public License](http://www.gnu.org/licenses/gpl.html)
-
-Copyrights are listed in chronological order, by contributions.
-
-wpDirAuth: WordPress Directory Authentication, original author
-Copyright (c) 2007 Stephane Daury - http://stephane.daury.org/
-
-wpDirAuth and wpLDAP Patch Contributions
-Copyright (c) 2007 PKR Internet, LLC - http://www.pkrinternet.com/
-
-wpDirAuth Patch Contributions
-Copyright (c) 2007 Todd Beverly
-
-wpLDAP: WordPress LDAP Authentication
-Copyright (c) 2007 Ashay Suresh Manjure - http://ashay.org/
-
-wpDirAuth Patch Contribution and current maintainer
-Copyright (c) 2010, 2011, 2012 Paul Gilzow - http://gilzow.com/
-
-wpDirAuth is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation.
-
-wpDirAuth is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-
-== Project History ==
-
-Originally started from a patched version of wpLDAP (1.02+patch), wpDirAuth has
-since then been heavily overhauled and features have been modified and added.
-In other words, a classic case of `pimp my lib'` (hopefully for the better).
-
-* Current: wpDirAuth:
-* Original: wpLDAP:
-* wpLDAP Patch:
-
-== Changelog ==
-
-PLEASE NOTE Beta testers of the 1.7.X branch prior to version 1.7.5, you will need to deactivate wpdirauth before you updgrade to this latest version. Once you have installed and network activated the plugin, it will copy your options from their previous location to the sitemeta table. You will only need to do this once. This will also work for anyone who was using the 1.6.X branch or older and plans on using it in MULTISITE mode.
-
-= 1.7.6 =
-Corrected situation where a new authenticated user logging into a child site in a multisite network was added to the parent site, instead of the child site where they initiated the login. Also, somewhere along the way, I reintroduced a bug that when using authentication groups, the plugin would fail to redirect a successfully logged in user.
-
-= 1.7.5 =
-* MULTISITE support, bug fixes, security enhancements
-
-= 1.6.1 =
-* Corrected a bug that would prevent user profiles from successfully being found. Thanks go to jgiangrande for identifying the problem area.
-
-= 1.6.0 =
-* Added `Add Dir Auth User` to Admin User menu. Now able to pre-add Directory Authenticated users and assign roles where previously users would have to log in first, and then have an admin change their role.
-
-= 1.5.2 =
-* Added ability to limit logins to specific AD groups. Fixed a bug that produced an incorrect filter when using a single Authentication Group
-
-= 1.5.1 =
+=== wpDirAuth ===
+Contributors: gilzow, stephdau, apokalyptik
+Tags: login, authentication, directory, ldap, ldaps
+Requires at least: 2.2
+Tested up to: 4.5
+Stable tag: 1.7.15
+WordPress directory authentication plugin through LDAP and LDAPS (SSL).
+== Description ==
+Please see changelog below for recent updates/changes.
+
+wpDirAuth allows users of central directory (LDAP) servers to login to
+authorized WordPress instances without having to register. The plugin creates
+a new account for each directory user on first login so that they have full
+access to preferences and functions, as any WP user would.
+Activating the plugin will not restrict you to using directory authentication
+and you will still be able to both create new WP-only users as well as turn on
+public registration in WordPress. You can also assign any privilege levels to
+your directory users, and the those users will be referred to their
+institutional password policy whenever they would normally able to update
+their WP passwords (on the profile screen, in user edit, etc).
+
+= LDAP/LDAPS =
+Authentication should work with most LDAP enabled directory services, such as
+OpenLDAP, Apache Directory, Microsoft Active Directory, Novell eDirectory,
+Sun Java System Directory Server, and more.
+wpDirAuth supports LDAP and LDAPS (SSL) connectivity and can force SSL for
+WordPress authentication if it is available on the Web server. It also supports
+server connection pools, for pseudo load balancing and fault tolerance, or
+multiple source directory authentication.
+Because the key used to locate a user's profile in the LDAP server is not
+always the same, depending on your LDAP server type and institutional choices,
+you can define your own through the wpDirAuth administration tool.
+When logging in as a directory user, the WP "remember me" feature is downgraded
+from 6 months for regular WP users to only 1 hour, so that institutional
+passwords are not overly endangered when accessing WP from public terminals.
+
+= Branding & Notifications =
+You can define notifications addressed to your directory users in key WordPress
+areas, such as the login screen and the profile edit screen.
+Since these admin-editable values support HTML (admin, coders, beware of xss!),
+you can point your directory users to central support information related to
+functions such as changing their institutional password, a WordPress usage
+related policy, etc.
+There is also a simple and optional terms of services concept, only implemented
+for directory users, which will simply record a one-time acceptance date when
+agreed upon. Note that agreeing to the TOS has no effect on the user's level of
+access in the system, fact which could change in future version if there is a
+demand for it, or through direct code contribution to that effect.
+
+== Download ==
+You can download the latest stable version of wpDirAuth from the WordPress
+Plugin Finder at the following locations:
+* Direct download:
+* WPPF home:
+
+== Installation ==
+Installing should be a piece of cake and take fewer than ten minutes, provided
+you know your directory server(s) information, and that your blog is allowed to
+connect and bind to it/them.
+Please refer to your friendly neighbourhood LDAP sysadmin for more information.
+Or use a LDAP browser (e.g. Apache Directory Studio) to test/research what your
+specific connections settings need to be.
+1. Upload the `wpDirAuth` directory to the `/wp-content/plugins/` directory.
+1. Login to your WordPress instance as an admin user.
+1. Activate the plugin through the 'Plugins' menu in WordPress.
+1. Go to the `Directory Auth.` menu found in the WordPress `Options` section.
+1. Enter your directory server(s) information and set your preferences.
+You should now be able to login as a directory user.
+== Using wpDirAuth ==
+Once installed and activated, you will be able to administer your directory
+settings through the dedicated plugin configuration tool found under the
+`Directory Auth.` menu found in the WordPress `Options` admin section.
+Directory Authenticated users can now be pre-added to your wordpress system
+and granted roles by going to the `Add Dir Auth User` menu found in the
+Wordpress `Users` admin section. Contextual help for this section is
+available for this section within Wordpress' built-in help menu.
+See the inline help found in the tool for more information on the settings.
+There is a secondary activation toggle, so you can install and activate the
+plugin, check out the options panel, but not immediately accept directory
+authentication, or even simply turn the feature on or off at any time.
+
+== Help and Support ==
+Please post questions, request for help to the Wordpress plugins forum or
+email . Please be sure to include 'wpdirauth' in the
+subject line.
+
+== TO-DO's ==
+Tons. The entire codebase could stand refactoring.
+
+== Source and Development ==
+wpDirAuth welcomes friendly contributors wanting to lend a hand, be it in
+the form of code through SVN patches, user support, platform portability
+testing, security consulting, localization help, etc.
+The [current] goal is to keep the plugin self-contained (ie: no 3rd-party lib)
+for easier security maintenance, while keeping the code clean and extensible.
+Focus is on security, features, security, and let's not forget, security.
+Unit tests will hopefully be developed and constant security audit performed.
+Recurring quality patch contributions will lead to commit privileges to the
+project source repository.
+Please post questions/requests for help to the wordpress forums and/or
+email
+The project source code is available on the WordPress Plugin Repository:
+* Stable:
+* Unstable:
+* Historical:
+The Sybversion repository can be browsed and tracked (RSS, etc) through the
+WP Plugin Repo source browser at:
+*
+The generated code documentation can be found at:
+*
+The WP Plugin Repo also offers a convenient ticketing system for bug and
+task tracking.
+* Existing tickets:
+* Open a new ticket:
+== License ==
+[General Public License](http://www.gnu.org/licenses/gpl.html)
+Copyrights are listed in chronological order, by contributions.
+wpDirAuth: WordPress Directory Authentication, original author
+Copyright (c) 2007 Stephane Daury - http://stephane.daury.org/
+wpDirAuth and wpLDAP Patch Contributions
+Copyright (c) 2007 PKR Internet, LLC - http://www.pkrinternet.com/
+
+wpDirAuth Patch Contributions
+Copyright (c) 2007 Todd Beverly
+wpLDAP: WordPress LDAP Authentication
+Copyright (c) 2007 Ashay Suresh Manjure - http://ashay.org/
+wpDirAuth Patch Contribution and current maintainer
+Copyright (c) 2010, 2011, 2012 Paul Gilzow - http://gilzow.com/
+wpDirAuth is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation.
+wpDirAuth is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+== Project History ==
+Originally started from a patched version of wpLDAP (1.02+patch), wpDirAuth has
+since then been heavily overhauled and features have been modified and added.
+In other words, a classic case of `pimp my lib'` (hopefully for the better).
+* Current: wpDirAuth:
+* Original: wpLDAP:
+* wpLDAP Patch:
+== Changelog ==
+= 1.7.15 =
++ let's try this again. filter wpdirauth_filterquery will pass THREE parameters: current AD filter, the account filter as set in the wpDirAuth settings and the username of the person attempting to authenticate. Callback function must pass back a valid AD filter.
+= 1.7.14 =
++ Why no 1.7.13? Because I'm superstitious.
++ Added hookable filter wpdirauth_filterquery. Will pass 2 parameters: the current AD filter and the username of the person attempting to authenticate. Callback function must pass back a valid AD filter.
++ v4.4.2 of wordpress changed some of the roles & caps. Role create_users no longer allows admins who do not posses super-admin privilege in a multisite to see the wpDirAuth add user menu item when in a site. changed the cap to add_users, but will continue to research
+= 1.7.12 =
+missed an instance of split (deprecated php function).
+= 1.7.11 =
+Adding stripslashes_deep because wordpress.
+= 1.7.10 =
+Bug fixes and minor clean-up
+= 1.7.9 =
+* The plugin no longer automatically creates accounts for directory-authenticated users who log into the site. You can enable this behavior in the plugin settings, but it is no longer the default behavior.
+* Not sure why but I never set the plugin up to block Directory-Authenticated users from attempting to use the wordpress builtin password reset tool. It can't actually change the password, but it definitely caused confusion among users. wpDirAuth now blocks directory-authenticated users from using the password reset tool.
+* Removed a bunch of deprecated function calls.
+* Cleaned up some of the debugging messages.
+= 1.7.6 =
+Corrected situation where a new authenticated user logging into a child site in a multisite network was added to the parent site, instead of the child site where they initiated the login. Also, somewhere along the way, I reintroduced a bug that when using authentication groups, the plugin would fail to redirect a successfully logged in user.
+= 1.7.5 =
+* PLEASE NOTE Beta testers of the 1.7.X branch prior to version 1.7.5, you will need to deactivate wpdirauth before you updgrade to this latest version. Once you have installed and network activated the plugin, it will copy your options from their previous location to the sitemeta table. You will only need to do this once. This will also work for anyone who was using the 1.6.X branch or older and plans on using it in MULTISITE mode.
+* MULTISITE support, bug fixes, security enhancements
+= 1.6.1 =
+* Corrected a bug that would prevent user profiles from successfully being found. Thanks go to jgiangrande for identifying the problem area.
+= 1.6.0 =
+* Added `Add Dir Auth User` to Admin User menu. Now able to pre-add Directory Authenticated users and assign roles where previously users would have to log in first, and then have an admin change their role.
+= 1.5.2 =
+* Added ability to limit logins to specific AD groups. Fixed a bug that produced an incorrect filter when using a single Authentication Group
+= 1.5.1 =
* Remove default password nag for wpdirauth accounts
\ No newline at end of file
diff --git a/wpDirAuth.php b/wpDirAuth.php
index 822209a..263c7f8 100644
--- a/wpDirAuth.php
+++ b/wpDirAuth.php
@@ -1,53 +1,53 @@
- *
+ *
* Copyrights are listed in chronological order, by contributions.
- *
+ *
* wpDirAuth: WordPress Directory Authentication, original author
* Copyright (c) 2007 Stephane Daury - http://stephane.daury.org/
- *
+ *
* wpDirAuth and wpLDAP Patch Contributions
* Copyright (c) 2007 PKR Internet, LLC - http://www.pkrinternet.com/
- *
+ *
* wpDirAuth Patch Contributions
* Copyright (c) 2007 Todd Beverly
- *
+ *
* wpLDAP: WordPress LDAP Authentication
* Copyright (c) 2007 Ashay Suresh Manjure - http://ashay.org/
- *
+ *
* wpDirAuth Patch Contribution and current maintainer
* Copyright (c) 2010, 2011, 2012 Paul Gilzow - http://gilzow.com/
- *
+ *
* wpDirAuth is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation.
- *
+ *
* wpDirAuth is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
- *
+ *
* @todo Always stay on top of security and user input validation while
* staying backwards compatible enough until PHP4 support is dropped in
* WP (serious patches welcomed, please see code). Note that we do
@@ -56,14 +56,14 @@
/*
PLUGIN META INFO FOR WORDPRESS LISTINGS
-Plugin Name: wpDirAuth-PosixGroup
+Plugin Name: wpDirAuth
Plugin URI: http://wpdirauth.gilzow.com/
Description: WordPress Directory Authentication (LDAP/LDAPS).
Works with most LDAP enabled directory services, such as OpenLDAP,
Apache Directory, Microsoft Active Directory, Novell eDirectory,
Sun Java System Directory Server, etc.
Originally revived and upgraded from a patched version of wpLDAP.
-Version: 1.7.6
+Version: 1.7.15
Author: Paul Gilzow
Author URI: http://gilzow.com/
*/
@@ -71,7 +71,7 @@ Author URI: http://gilzow.com/
/**
* wpDirAuth version.
*/
-define('WPDIRAUTH_VERSION', '1.7.6');
+define('WPDIRAUTH_VERSION', '1.7.15');
/**
* wpDirAuth signature.
@@ -105,12 +105,12 @@ define('WPDIRAUTH_LDAP_RETURN_KEYS',serialize(array('sn', 'givenname', 'mail')))
define('WPDIRAUTH_EMAIL_NEWUSER_NOTIFY','You have been added to the site %s as %s %s. You may login to the site using your institution\'s %s (%s) and password at the following address: %s');
/**
- *My fail-safe method for determing if we are running in multisite mode
+ *My fail-safe method for determing if we are running in multisite mode
*/
define('WPDIRAUTH_MULTISITE',(defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE && function_exists('switch_to_blog')) ? TRUE : FALSE);
/**
- *List of option keys we store in wp_sitemeta/wp_options
+ *List of option keys we store in wp_sitemeta/wp_options
*/
define('WPDIRAUTH_OPTIONS', serialize(array(
'dirAuthEnable',
@@ -132,20 +132,20 @@ define('WPDIRAUTH_OPTIONS', serialize(array(
if (function_exists('wp_authenticate') || function_exists('wp_setcookie') || !function_exists('ldap_connect')) {
-/**
- * SAFE MODE
- */
-
+ /**
+ * SAFE MODE
+ */
+
/**
* SAFE MODE: wpDirAuth plugin configuration panel.
* Processes and outputs the wpDirAuth configuration form, with a conflict message.
- *
+ *
* @return void
*/
function wpDirAuth_safeConflictMessage()
{
$wpDARef = WPDIRAUTH_SIGNATURE;
-
+
if (!function_exists('ldap_connect')) {
$message = <<<________EOS
Sorry, but your PHP install does not seem to have access to the LDAP features.
@@ -181,30 +181,30 @@ ________EOS;
________EOS;
}
-
+
echo <<<________EOS
Directory Authentication Options: Plugin Conflict
$message
$wpDARef
-
+
________EOS;
}
-
+
/**
* SAFE MODE: Adds the `Directory Auth.` menu entry in the Wordpress Admin section.
* Also activates the wpDirAuth config panel, with a conflict message, as a callback function.
- *
+ *
* @uses wpDirAuth_safeConflictMessage
*/
- function wpDirAuth_safeAddMenu()
+ function wpDirAuth_safeAddMenu()
{
if (function_exists('add_options_page')) {
add_options_page(
'Directory Authentication Options: Plugin Conflict',
'!! Directory Auth. !!',
- 9,
+ 'manage_options',
basename(__FILE__),
'wpDirAuth_safeConflictMessage'
);
@@ -214,18 +214,18 @@ ________EOS;
/**
* SAFE MODE: Add custom WordPress actions.
- *
+ *
* @uses wpDirAuth_safeAddMenu
*/
if (function_exists('add_action')) {
add_action('admin_menu', 'wpDirAuth_safeAddMenu');
- }
+ }
}
else {
-/**
- * STANDARD MODE
- */
-
+ /**
+ * STANDARD MODE
+ */
+
/**
* Cookie marker.
* Generates a random string to be used as salt for the password
@@ -236,21 +236,21 @@ else {
function wpDirAuth_makeCookieMarker()
{
$cookieMarker = md5(
- $_SERVER['SERVER_SIGNATURE']
- .$_SERVER['HTTP_USER_AGENT']
- .$_SERVER['REMOTE_ADDR']
- ).uniqid(microtime(),true);
+ $_SERVER['SERVER_SIGNATURE']
+ .$_SERVER['HTTP_USER_AGENT']
+ .$_SERVER['REMOTE_ADDR']
+ ).uniqid(microtime(),true);
update_site_option("dirAuthCookieMarker",$cookieMarker);
return $cookieMarker;
}
-
-
+
+
/**
* LDAP bind test
* Tries two different documented method of php-based ldap binding.
* Note: passing params by reference, no need for copies (unlike in
* wpDirAuth_auth where it is desirable).
- *
+ *
* @param object &$connection LDAP connection
* @param string &$username LDAP username
* @param string &$password LDAP password
@@ -259,33 +259,38 @@ else {
* */
function wpDirAuth_bindTest(&$connection, &$username, &$password,$baseDn)
{
- $password = strtr($password, array("\'"=>"'"));
+ //$password = strtr($password, array("\'"=>"'"));
+ /**
+ * Why stripslashes on the password? Because wordpress.
+ * @see: https://codex.wordpress.org/Function_Reference/stripslashes_deep#Good_Coding_Practice
+ */
+ $password = stripslashes_deep($password);
if ( ($isBound = @ldap_bind($connection, $username, $password)) === false ) {
// @see http://weblogs.valsania.it/andreav/2008/07/24/wpdirauth-14-patch/
$isBound = @ldap_bind($connection,"uid=$username,$baseDn", $password);
}
return $isBound;
}
-
+
/**
- * put your comment there...
- *
- * @param string $dc name of domain controller to connect to
- * @param integer $enableSsl ssl config option
- * @return resource
- */
+ * put your comment there...
+ *
+ * @param string $dc name of domain controller to connect to
+ * @param integer $enableSsl ssl config option
+ * @return resource
+ */
function wpDirAuth_establishConnection($dc,$enableSsl){
/**
* Only setup protocol value if ldaps is required to help with older AD
* @see http://groups.google.com/group/wpdirauth-support/browse_thread/thread/7b744c7ad66a4829
*/
$protocol = ($enableSsl) ? 'ldaps://' : '';
-
+
/**
* Scan for and use alternate server port, but only if ssl is disabled.
* @see Parameters constraint at http://ca.php.net/ldap_connect
*/
-
+
if (strstr($dc, ':')) list($dc, $port) = explode(':', $dc);
switch($enableSsl){
@@ -299,11 +304,11 @@ else {
$connection = ldap_connect($dc,$port);
} else {
$connection = ldap_connect($dc);
- }
- break;
+ }
+ break;
}
-
+
/**
* Copes with W2K3/AD issue.
* @see http://bugs.php.net/bug.php?id=30670
@@ -311,34 +316,34 @@ else {
if (@ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3)) {
@ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
}
-
+
//they want to start TLS
if($enableSsl == 2){
if(!ldap_start_tls($connection)){
return new WP_Error('tls_failed_to_start',__('wpDirAuth error: tls failed to start'));
}
- }
-
- return $connection;
+ }
+
+ return $connection;
}
/**
- * put your comment there...
- *
- * @param array $controllers list of domain controllers to connect to
- * @return mixed array of shuffled controllers or WP_Error
- */
+ * put your comment there...
+ *
+ * @param array $controllers list of domain controllers to connect to
+ * @return mixed array of shuffled controllers or WP_Error
+ */
function wpDirAuth_shuffleControllers($controllers){
if (count($controllers) > 1) {
// shuffle the domain controllers for pseudo load balancing and fault tolerance.
shuffle($controllers);
} elseif (count($controllers) == 0) {
return new WP_Error('no_controllers',__(' wpDirAuth config error: no domain controllers specified.'));
- }
-
- return $controllers;
+ }
+
+ return $controllers;
}
-
+
/**
* Custom LDAP authentication module.
* The returned keys are in the same format used by WP for
@@ -347,7 +352,7 @@ else {
* @param string $username LDAP username
* @param string $password LDAP password
* @return WP_Error object OR array Directory email, last_name and first_name
- *
+ *
* @uses WPDIRAUTH_DEFAULT_FILTER
* @uses WPDIRAUTH_ERROR_TITLE
* @uses wpDirAuth_bindTest
@@ -357,10 +362,11 @@ else {
*/
function wpDirAuth_auth($username, $password)
{
- global $error, $pwd;
-
+ global $error, $pwd;
+
$errorTitle = WPDIRAUTH_ERROR_TITLE;
-
+ $isInDirectory = false;
+ $results = false;
$controllers = explode(',', get_site_option('dirAuthControllers'));
$baseDn = get_site_option('dirAuthBaseDn');
$preBindUser = get_site_option('dirAuthPreBindUser');
@@ -369,36 +375,38 @@ else {
$filter = get_site_option('dirAuthFilter');
$enableSsl = get_site_option('dirAuthEnableSsl');
$boolUseGroups = get_site_option('dirAuthUseGroups');
-
+
if($boolUseGroups == 1){
$strAuthGroups = get_site_option('dirAuthGroups');
}
-
+
$returnKeys = unserialize(WPDIRAUTH_LDAP_RETURN_KEYS);
-
+
$isBound = $isPreBound = $isLoggedIn = false;
-
+
if ($accountSuffix) $username .= $accountSuffix;
-
+
if (!$filter) $filter = WPDIRAUTH_DEFAULT_FILTER;
-
+
$filterQuery = "($filter=$username)";
-
+
+ $filterQuery = apply_filters('wpdirauth_filterquery',$filterQuery,$filter,$username);
+
$controllers = wpDirAuth_shuffleControllers($controllers);
-
+
if(is_wp_error($controllers)){
return $controllers;
}
-
- // Connection pool loop - Haha, PooL LooP
+
+ // Connection pool loop - Haha, PooL LooP
foreach ($controllers as $dc) {
-
+
$connection = wpDirAuth_establishConnection($dc,$enableSsl);
-
+
if(is_wp_error($connection)){
return $connection;
}
-
+
if ($preBindUser && $preBindPassword) {
/**
* Use case 1: Servers requiring pre-binding with admin defined
@@ -444,38 +452,35 @@ else {
}
}
}
-
+
if ( ($preBindUser && $preBindPassword) && ( ! $isPreBound ) ) {
return new WP_Error ('no_directory_or_prebinding', $errorTitle
- . __(' wpDirAuth config error: No directory server available for authentication, OR pre-binding credentials denied.'));
+ . __(' wpDirAuth config error: No directory server available for authentication, OR pre-binding credentials denied.'));
}
- elseif ( ( $isInDirectory ) && ( ! $isBound ) ) {
+ elseif ( ( $isInDirectory ) && ( ! $isBound ) ) {
return new WP_Error ('could_not_bind_as_user', $errorTitle
- . __(' Incorrect password.'));
- }
+ . __(' Incorrect password.'));
+ }
elseif ( ! $isBound && ! $isPreBound ) {
return new WP_Error ('no_directory_available', $errorTitle
- . __(' wpDirAuth config error: No directory server available for authentication.'));
+ . __(' wpDirAuth config error: No directory server available for authentication.'));
}
elseif ( ! $isLoggedIn) {
/**
- * @desc wp-hack was echo'ing out $username verbatim which allowed a XSS vulnerability. Encoded $username before echoing'
- */
+ * @desc wp-hack was echo'ing out $username verbatim which allowed a XSS vulnerability. Encoded $username before echoing'
+ */
return new WP_Error ('could_not_authenticate', $errorTitle
- . __(' Could not authenticate user. Please check your credentials.')
- . " [" . htmlentities($username,ENT_QUOTES,'UTF-8') . "]");
+ . __(' Could not authenticate user. Please check your credentials.')
+ . " [" . htmlentities($username,ENT_QUOTES,'UTF-8') . "]");
+
-
}
else {
if($boolUseGroups == 1){
//the user is authenticated, but we want to make sure they are a member of the groups given
/**
- * We need to get the DN's for each Authentication Group CN that was given to us.
- */
-
- // 2014-07-06 Nikolai R Kristiansen
- // Modified for posixGroup lookup
+ * We need to get the DN's for each Authentication Group CN that was given to us.
+ */
$aryAuthGroupsDN = array();
$aryAuthGroups = explode(',',$strAuthGroups);
$aryAttribs = array('distinguishedname');
@@ -484,20 +489,18 @@ else {
$rscLDAPSearch = ldap_search($connection,$baseDn,$strAuthGroup,$aryAttribs);
$arySearchResults = ldap_get_entries($connection,$rscLDAPSearch);
if(isset($arySearchResults[0]['dn'])){
- $aryAuthGroupsDN[] = $strAuthGroup;
- }
+ $aryAuthGroupsDN[] = $arySearchResults[0]['dn'];
+ }
}
-
+
if(count($aryAuthGroupsDN) == 0){
return new WP_Error('no_auth_groups_found',$errorTitle.__('No Authentication Groups found based on given group CN'));
- }
-
- // (&(memberUid=nikolark)(cn=dns-aktiv))
- // TODO configurable memberUid and cn
- $memberFilterQuery = "(memberUid=$username)";
- $strFilterQuery = '(&'.$memberFilterQuery.'(|';
+ }
+
+
+ $strFilterQuery = '(&'.$filterQuery.'(|';
foreach($aryAuthGroupsDN as $strAuthGroupDN){
- $strFilterQuery .= "($strAuthGroupDN)";
+ $strFilterQuery .= '(memberOf='.$strAuthGroupDN.')';
}
$strFilterQuery .= '))';
if(($rscLDAPSearchGroupMember = ldap_search($connection,$baseDn,$strFilterQuery)) !== false){
@@ -507,33 +510,32 @@ else {
. __('User authenticated but is not a member of an Authentication Group(s)'));
}
}
-
- }
-
-
+
+ }
+
+
/**
* Search for profile, if still needed.
- * @see $results in preceding loop: Use case 3
+ * $result is set to false by default. reset to a resource or false again in lines 403-437
+ * wpDirAuth_retrieveUserDetails() now checks the value of $results before continuing
*/
- if (!$results){
- return wpDirAuth_retrieveUserDetails($connection,$baseDn,$filterQuery);
- } else {
- return wpDirAuth_retrieveUserDetails($connection,$baseDn,$filterQuery,$results);
- }
+
+ return wpDirAuth_retrieveUserDetails($connection,$baseDn,$filterQuery,$results);
+
}
}
-
-
+
+
/**
* Runs stripslashes, html_entity_decode, then strip_tags with
* allowed html if requested.
- *
+ *
* No input sashimi for us (hopefully).
*
* @param string $value Value to `sanitize`
* @param boolean $allowed Set to true for WPDIRAUTH_ALLOWED_TAGS
* @return string Cleaner value.
- *
+ *
* @uses WPDIRAUTH_ALLOWED_TAGS
*/
function wpDirAuth_sanitize($value, $allowed = false)
@@ -541,14 +543,14 @@ else {
$allowed = ($allowed) ? WPDIRAUTH_ALLOWED_TAGS : '';
return strip_tags(html_entity_decode(stripslashes($value)), $allowed);
}
-
-
+
+
/**
* wpDirAuth plugin configuration panel.
* Processes and outputs the wpDirAuth configuration form.
- *
+ *
* @return void
- *
+ *
* @uses WPDIRAUTH_DEFAULT_FILTER
* @uses WPDIRAUTH_DEFAULT_LOGINSCREENMSG
* @uses WPDIRAUTH_DEFAULT_CHANGEPASSMSG
@@ -559,12 +561,12 @@ else {
function wpDirAuth_optionsPanel()
{
global $userdata;
-
+
$wpDARef = WPDIRAUTH_SIGNATURE;
$allowedHTML = htmlentities(WPDIRAUTH_ALLOWED_TAGS);
-
- $curUserIsDirUser = get_usermeta($userdata->ID, 'wpDirAuthFlag');
-
+
+ $curUserIsDirUser = get_user_meta($userdata->ID, 'wpDirAuthFlag',true);
+
if ($curUserIsDirUser) {
echo <<<____________EOS
@@ -581,11 +583,11 @@ else {
using the appropriate WordPress admin tool.
$wpDARef
-
+
____________EOS;
return;
}
-
+
if ($_POST) {
$enableSsl = 0; //default
$boolUseGroups = 0; //default
@@ -593,13 +595,14 @@ ____________EOS;
$enable = intval($_POST['dirAuthEnable']) == 1 ? 1 : 0;
$requireSsl = intval($_POST['dirAuthRequireSsl']) == 1 ? 1 : 0;
$TOS = intval($_POST['dirAuthTOS']) == 1 ? 1 : 0;
-
+ $boolAutoRegister = intval($_POST['dirAuthAutoRegistration'])== 1 ? 1 : 0;
+ _wpdirauth_log($boolAutoRegister,'value for autoregister passed via POST',false,array('line'=>__LINE__,'file'=>__FILE__));
//integers
if(intval($_POST['dirAuthEnableSsl']) == 1 || intval($_POST['dirAuthEnableSsl']) == 2){
- $enableSsl = intval($_POST['dirAuthEnableSsl']);
+ $enableSsl = intval($_POST['dirAuthEnableSsl']);
}
-
-
+
+
// Strings, no HTML
$controllers = wpDirAuth_sanitize($_POST['dirAuthControllers']);
$baseDn = wpDirAuth_sanitize($_POST['dirAuthBaseDn']);
@@ -613,16 +616,22 @@ ____________EOS;
$strMarketingSSOID= wpDirAuth_sanitize(($_POST['dirAuthMarketingSSOID']));
if($strAuthGroups != ''){
- $boolUseGroups = 1;
- }
-
+ $boolUseGroups = 1;
+ if(1 == $boolAutoRegister){
+ //they are using authgroups, but they also want us to autoregister. sorry, cant do that.
+ $boolAutoRegister = 0;
+ }
+ }
+
// Have to be allowed to contain some HTML
$loginScreenMsg = wpDirAuth_sanitize($_POST['dirAuthLoginScreenMsg'], true);
$changePassMsg = wpDirAuth_sanitize($_POST['dirAuthChangePassMsg'], true);
-
+
+ _wpdirauth_log($boolAutoRegister,'auto register before saving',false,array('line'=>__LINE__,'file'=>__FILE__));
update_site_option('dirAuthEnable', $enable);
update_site_option('dirAuthEnableSsl', $enableSsl);
update_site_option('dirAuthRequireSsl', $requireSsl);
+ update_site_option('dirAuthAutoRegister', $boolAutoRegister);
update_site_option('dirAuthControllers', $controllers);
update_site_option('dirAuthBaseDn', $baseDn);
update_site_option('dirAuthPreBindUser', $preBindUser);
@@ -636,33 +645,33 @@ ____________EOS;
update_site_option('dirAuthGroups', $strAuthGroups);
update_site_option('dirAuthMarketingSSOID', $strMarketingSSOID);
-
+
// Only store/override the value if a new one is being sent a bind user is set.
if ( $preBindUser && $preBindPassword && ($preBindPassCheck == $preBindPassword) )
update_site_option('dirAuthPreBindPassword', $preBindPassword);
-
+
// Clear the stored password if the Bind DN is null
elseif ( ! $preBindUser)
update_site_option('dirAuthPreBindPassword', '');
-
+
if (get_site_option('dirAuthEnable') && !get_site_option('dirAuthCookieMarker'))
wpDirAuth_makeCookieMarker();
-
+
echo 'Your new settings were saved successfully.
';
-
+
// Be sure to clear $preBindPassword, not to be displayed onscreen or in source
unset($preBindPassword);
- }
- else {
+ } else {
// Booleans
- $enable = intval(get_site_option('dirAuthEnable')) == 1 ? 1 : 0;
- $requireSsl = intval(get_site_option('dirAuthRequireSsl')) == 1 ? 1 : 0;
- $TOS = intval(get_site_option('dirAuthTOS')) == 1 ? 1 : 0;
- $boolUseGroups = intval(get_site_option('dirAuthUseGroups')) == 1 ? 1 : 0;
-
+ $enable = intval(get_site_option('dirAuthEnable')) == 1 ? 1 : 0;
+ $requireSsl = intval(get_site_option('dirAuthRequireSsl')) == 1 ? 1 : 0;
+ $TOS = intval(get_site_option('dirAuthTOS')) == 1 ? 1 : 0;
+ $boolUseGroups = intval(get_site_option('dirAuthUseGroups')) == 1 ? 1 : 0;
+ $boolAutoRegister= intval(get_site_option('dirAuthAutoRegister'))== 1 ? 1 : 0;
+
//integers
$enableSsl = intval(get_site_option('dirAuthEnableSsl',0));
-
+
// Strings, no HTML
$controllers = wpDirAuth_sanitize(get_site_option('dirAuthControllers'));
$baseDn = wpDirAuth_sanitize(get_site_option('dirAuthBaseDn'));
@@ -671,8 +680,8 @@ ____________EOS;
$filter = wpDirAuth_sanitize(get_site_option('dirAuthFilter'));
$institution = wpDirAuth_sanitize(get_site_option('dirAuthInstitution'));
$strAuthGroups = wpDirAuth_sanitize((get_site_option('dirAuthGroups')));
- $strMarketingSSOID = wpDirAuth_sanitize((get_site_option('dirAuthMarketingSSOID')));
-
+ $strMarketingSSOID = wpDirAuth_sanitize((get_site_option('dirAuthMarketingSSOID')));
+
// Have to be allowed to contain some HTML
$loginScreenMsg = wpDirAuth_sanitize(get_site_option('dirAuthLoginScreenMsg'), true);
$changePassMsg = wpDirAuth_sanitize(get_site_option('dirAuthChangePassMsg'), true);
@@ -687,31 +696,40 @@ ____________EOS;
$loginScreenMsg = htmlspecialchars($loginScreenMsg);
$changePassMsg = htmlspecialchars($changePassMsg);
$strAuthGroups = htmlspecialchars($strAuthGroups);
-
+
+ $tEnable = $fEnable = $tWpSsl = $fWpSsl = $tTOS = $fTOS = '';
+
if ($enable) {
$tEnable = "checked";
}
else {
$fEnable = "checked";
}
-
+
$defaultFilter = WPDIRAUTH_DEFAULT_FILTER;
if (!$filter) {
$filter = $defaultFilter;
}
-
+
if (!$institution) {
$institution = '[YOUR INSTITUTION]';
}
-
+
if (!$loginScreenMsg) {
$loginScreenMsg = sprintf(WPDIRAUTH_DEFAULT_LOGINSCREENMSG, $institution);
}
-
+
if (!$changePassMsg) {
$changePassMsg = sprintf(WPDIRAUTH_DEFAULT_CHANGEPASSMSG, $institution);
}
-
+
+ /**
+ * If they are using authentication groups we will not automaticaly register authed users that dont already have an account
+ */
+ if('' != $strAuthGroups && $boolAutoRegister == 1){
+ $boolAutoRegister = 0;
+ }
+
/*
if ($enableSsl) {
$tSsl = "checked";
@@ -733,34 +751,46 @@ ____________EOS;
break;
case 0:
default:
- $strNoSSL = $strOptionSelected;
+ $strNoSSL = $strOptionSelected;
break;
}
-
+
if ($requireSsl) {
$tWpSsl = "checked";
}
else {
$fWpSsl = "checked";
}
-
+
if ($TOS) {
$tTOS = "checked";
}
else {
$fTOS = "checked";
}
-
+
+ $strYesAutoRegister = '';
+ $strNoAutoRegister = '';
+ if($boolAutoRegister){
+ $strYesAutoRegister = 'checked';
+ } else {
+ $strNoAutoRegister = 'checked';
+ }
+
+ /**
+ * @todo seems like we should loop through these yes/nos are something...
+ */
+
$wpDAV = WPDIRAUTH_VERSION;
-
+
echo <<<________EOS
Directory Authentication Options
________EOS;
}
-
+
/**
* Adds the `Directory Auth.` menu entry in the Wordpress Admin section, and the `Add Directory Authenticated User` to the Users menu
* Also activates the wpDirAuth config panel as a callback function.
- *
+ *
* @uses wpDirAuth_optionsPanel
* @uses wpDirAuth_add_user_panel
*/
- function wpDirAuth_addMenu()
+ function wpDirAuth_addMenu()
{
if (function_exists('add_options_page')) {
- add_options_page(
+ $strWpAdminPage = add_options_page(
'Directory Authentication Options',
'Directory Auth.',
- 9,
+ 'manage_options',
basename(__FILE__),
'wpDirAuth_optionsPanel'
);
+
+ //$strWpAdminPanel is here in case we want to add a contextual help panel later
}
}
-
-
+
+
/**
* Extending WP's login_form.
* Enforces the admin defined SSL login preferences and adds a directory
* login related message to the standard WP login screen.
- *
+ *
* @uses WPDIRAUTH_DEFAULT_LOGINSCREENMSG
*/
function wpDirAuth_loginFormExtra()
{
if (get_site_option('dirAuthEnable')) {
-
+
if (isset($_SERVER['SCRIPT_URI']) && preg_match('|^http|',$_SERVER['SCRIPT_URI'])) {
$selfURL = $_SERVER['SCRIPT_URI'];
}
@@ -964,62 +1001,62 @@ ________EOS;
: $_SERVER["SCRIPT_NAME"].'?'.$_SERVER['QUERY_STRING'])
);
}
-
+
//_log('contents of selfurl: '.$selfURL);
-
-
+
+
if (get_site_option('dirAuthRequireSsl') && (!preg_match('|^https|',$selfURL))) {
$sslURL = str_replace('http://','https://',$selfURL);
-
+
$refreshJS = '" />';
$refreshMeta = '';
$refreshMsg = 'Please access the encrypted version of this page.';
-
+
if (headers_sent()) {
- echo $refreshJS.$refreshMeta.''.$refreshMsg.'