Using the LDAP Authentication Plugin for MediaWiki – The Basics (Part 1)

LDAP, MediaWiki

Configuring the LDAP Authentication plugin for MediaWiki can be a daunting task. In this series of posts, I’ll go over the basics of configuring the plugin for common environments. In a later series of posts, I’ll go into each environment in detail.

Part 1 will discuss basic password authentication for Active Directory (AD). Part 2 will discuss basic password authentication for LDAP domains with the posix schema. Part 3 will discuss enabling group restrictions and synchronization, and retrieving preferences for AD. Part 4 will discuss group restrictions and synchronization, and retrieving preferences for LDAP domains with the posix schema.

Basic MediaWiki administration experience is assumed. This series of posts should only be considered current for version 1.2a or 1.2b of the LDAP plugin.

Create a local sysop

Before enabling the plugin, you should create a user in the local wiki database that exists in AD, and promote that user to sysop. After the plugin is enabled, you will not be able to log in as any user who does not exist in AD.

Enabling the plugin

To enable the plugin, first download the current stable version, and place it at $IP/extensions/LdapAuthentication/LdapAuthentication.php. After downloading the plugin, place the following in LocalSettings.php:

require_once( "$IP/extensions/LdapAuthentication/LdapAuthentication.php" );
$wgAuth = new LdapAuthenticationPlugin();

Configuring the plugin

For basic password authentication against an AD domain, you need to configure three things:

  1. Domain name
  2. Server names
  3. How to bind to the AD servers

Setting the domain name

The domain name is used for all of the LDAP configuration settings, and is also the domain name visible to users when logging in. It is recommended to use the short name of your AD domain as the domain name. For example, if your AD domain is TESTAD.EXAMPLE.COM, then you should use TESTAD as your domain name. We will use TESTAD for the examples in this post.

Place the following in LocalSettings.php file to set the domain name:

$wgLDAPDomainNames = array( "TESTAD" );

Setting the server names

The plugin needs to know the fully qualified domain name (FQDN) of each of your AD servers to contact. Currently, the plugin can not do automatic domain discovery. You may add multiple servers, delimited by spaces, for server failover.

Place the following in LocalSettings.php to set the server names:

$wgLDAPServerNames = array( "TESTAD" => "adserver1.testad.example.com adserver2.testad.example.com" );

Telling the plugin how to bind to the AD server

Binding to AD is straightforward; you simply tell the server the domain, username, and password. AD takes the domain and the username in either of the following formats: username@DOMAIN or DOMAINusername. The LDAP plugin supports either of these formats; for this example we’ll use the former.

To specify the format to bind with, place the following into LocalSettings.php:

$wgLDAPSearchStrings = array( "TESTAD" => "USER-NAME@TESTAD" );

Notice that USER-NAME is a special string, and should not be modified. When the user logs in, USER-NAME will be replaced with whatever username is used.

By default the LDAP plugin is set to bind using encryption. Specifically, the plugin defaults to tls using LDAP (port 389). AD doesn’t support tls, so the encryption type needs to be changed. The supported encryption types are clear, tls, and ssl. AD doesn’t allow clear text binds by default, and only supports the ssl encryption type using LDAPS (port 636). If you wish to use clear text binds, you’ll need to change your AD security settings (not recommended).

To change the encryption type, place the following into LocalSettings.php:

$wgLDAPEncryptionType = array( "TESTAD" => "ssl" );

Configuring the server

Configuring the SSL trust

For ssl to work properly, it is important to ensure the LDAP client (the web server) trusts the root Certificate Authority (CA) of the AD server. If your organization is using a third party CA that is in most normal trust lists (like in IE or Firefox), this step can likely be skipped. If your AD servers are using self signed certificates or a local CA, this step is needed.

You can find out which CA issued the AD server’s certificate using openssl. Run the following command:

openssl s_client -connect adserver1.testad.example.com:636 | egrep "subject|issuer"

If the subject and the issuer are the same, the certificate is self signed. If the subject and issuer are not the same, the certificate was signed by a CA. If the CA is local, ask someone in your organization for a copy of the CA certificate. If the certificate is self signed, you can get the certificate by running the previous command without the grep:

openssl s_client -connect adserver1.testad.example.com:636

Copy everything in between, and including:

-----BEGIN CERTIFICATE-----

and:

-----END CERTIFICATE-----

Paste the text into a file, and place the file wherever your OS normally stores its CA certificates; Red Hat Enterprise Linux 5 and newer versions of Fedora place these in /etc/pki/tls/certs.

Now place the following into /etc/openldap/ldap.conf:

TLS_CACERT     <pathToCACert>
TLS_CACERTFILE <pathToCACert>

Restart your web server for this to take effect.

Test your configuration by logging in with an AD user

Everything should be working at this point. If you have any questions, you should post them on the discussion page for the plugin on mediawiki.org, or leave me a comment (the former is preferred).

Related posts:

  1. Using the LDAP Authentication Plugin for MediaWiki – The Basics (Part 2)
  2. Using the LDAP Authentication Plugin for MediaWiki – The Basics (Part 3)
  3. Semi-anonymous users in MediaWiki using the LDAP Authentication extension
  4. New OpenSSO authentication plugin for MediaWiki
  5. OpenSSO web agent conflicts with the MediaWiki parser, and a workaround
77 Comments

77 Responses to “Using the LDAP Authentication Plugin for MediaWiki – The Basics (Part 1)”

  1. eDRoaCH says:

    Thanks so much for this series of posts, its very much what is needed. I did not yet see a link back from your plugin page, you may want to put that up near the top.

    BTW- your tags completely fail in IE, cant even read the text.

    • Ryan Lane says:

      Argh, IE. I tested the theme at one point in time in IE, but something broke along the way (I’ve done template modifications). I think something got cached improperly in one of the in between states. I think I have it fixed now.

      Like I mention on my plugin page, I don’t have a suitable Windows test environment; so, like most things, Microsoft products kind of lag behind in support.

      Thanks for the comment. I’m glad to know the post is helpful!

      • eDRoaCH says:

        I know I know, everyone hates IE. With 6 there was good reason, but I quite like 7, plan to upgrade to 8 very soon.

        Anyway it now works for all but 3 of them, i believe because the lines are too long causing the scoll bar to appear and cover everything up.

  2. eDRoaCH says:

    Not sure if you want this here, but…
    I’ve got everything working until the SSL key import. I am simply not sure how to import it under Ubuntu 8.04. All tutorials I have found talk about setting up a domain server, which is beyond what I want. there is supposed to be an /etc/ldap/ldap.conf and a /etc/ldap.conf. I have the first one but not the second.

    With SSL everything is just fine till an inexplicable ‘Failed to bind as my_name@THEDOMAIN. I did have to hack underscores into your script via the tip on the talk page of the plugin.

    • Ryan Lane says:

      Funny enough, I’ve never used the ldap plugin on debian/ubuntu. However….

      It looks like you need the libpam-ldap libnss-ldap nss-updatedb libnss-db packages installed. It also looks like ubuntu has the files /etc/libnss-ldap.conf and /etc/pam_ldap.conf.

      You want to ensure /etc/libnss-ldap.conf is correct. This is likely the file that will affect PHP, unless php5-ldap uses a separate config file. /etc/openldap/ldap.conf in fedora (/etc/libnss_ldap.conf in ubuntu) is used for all openldap client configuration, and /etc/ldap.conf (/etc/pam_ldap.conf in ubuntu) is used for pam ldap configuration. I usually just link one to the other; I’m not sure how that would affect ubuntu though.

  3. eDRoaCH says:

    Is it possible to get more info than

    Binding as the user
    Failed to bind as NKUSA\My_Username
    with password: MyPassword
    Entering allowPasswordChange
    Entering modifyUITemplate

    I have tried with the username@domain format as well, and recently hard-coded the username in the localsettings.php file.
    Debug level 4, everything above (connecting to ldaps, etc) is successful

    • Ryan Lane says:

      Check your Active Directory server and see if you are even binding. Just because the debug logs say the plugin connected successfully, doesn’t mean it did. In PHP, the ldap connect method returns success if it initializes its connection parameters (if you have php5-ldap, it’ll return success). I should really change the debug to say something other than “connected successfully” since it is somewhat misleading.

      Try connecting to your AD server from the command line with ldapsearch:

      ldapsearch -x -D "username@fully.qualified.domain" -W -b "root" '(samaccountname=)'
      

      You can find the above root for your domain by running:

      ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
      

      It’ll likely look like: DC=fully,DC=qualified,DC=domain

      If the ldapsearch won’t complete because it doesn’t trust your AD server, then PHP won’t work either.

  4. eDRoaCH says:

    Finally got it. Stupid mistake of mine I guess. I had domain\USER-NAME I did not add the .local though. I changed it to USER-NAME@domain.local (looked to weird the other way) and it is working!

    I still have to change TLS_REQCERT never to use the cert I downloaded instead, is there a preferred extension/location for the cert? I plan on just dropping it in /etc/ldap/ if not.

    Also, this is not a fancy setup, just making it so all domain users have an account as long as their AD account is active. So I shouldn’t need groups/etc. That should make me ‘done’ after this part of the tutorial, but I want to make sure of a few things
    1. users cant use local authentication to the wiki (mediawiki default)
    2. password recovery email will not work (security issue)
    3. How can I check if my domain user is a sysop?

    I posted over on Ubuntuforums and was given a link to a very nice AD testing script, may be useful to other readers: http://ubuntuforums.org/showthread.php?t=1140020
    Here’s the script
    http://adldap.sourceforge.net/wiki/doku.php?id=api

    Thanks much for the help!

    • Ryan Lane says:

      1. As long as you don’t have $wgLDAPUseLocal = true; user’s can’t use local authentication
      2. This shouldn’t work. In fact, as far as I can see on my wiki, I don’t even see a way to try it. It is disabled.
      3. Starting from the toolbox on the bottom left, click on Special pages->User rights management; then enter your (wiki) user name. You should really make your user a sysop before enabling LDAP.

      Glad to see you have it working.

  5. eDRoaCH says:

    Answering my own questions…
    TLS_CACERT /etc/ldap/cacerts/nkusa2.crt added to /etc/ldap/ldap.conf works great. The reason there’s a 2 there is I had to remove the
    —–BEGIN CERTIFICATE—– and
    —–END CERTIFICATE—– to get it to work.

    As for 3. I added myself as an Sysop and Bureaucrat, but when I log in I am not one. As all of my domain logins use underscores, I assumed that the mediawiki user should not have an underscore. Am I wrong in that or am I missing something?

  6. Ahriman says:

    I’m not sure if this is a newbie stupid question, but here it goes anyway.

    I’m trying to set up a wiki using AD authentication in a very simple way (single domain requiring search before binding, using a proxy agent). My personal AD user is the only wiki’s SysOp and everithing works fine, but one problem is driving me crazy…

    When I try to create a new wiki user (using my SysOp user) I must provide the user’s AD password in order to create it. Is there a way to create a new user without having to suply its AD password (of course I want it authenticate against its AD password when it will use wiki after its creation)?

    Thank you so much!
    (sorry for my poor English)

  7. DGseam says:

    I’m getting a blank page on site now; and verified as much from this information as possible. I can bind to AD through LDAP Search, but the following appears in my httpd error_logs:
    [client 192.168.30.209] PHP Fatal error: Class ldapauthenticationplugin: Cannot inherit from undefined class authplugin in /var/www/html/wiki/extensions/LdapAuthentication/LdapAuthentication.php on line 65

    I’ve tried both the 1.2a and 1.2b versions of the LdapAuthentication.php file.. and both produce same error.

    • Ryan Lane says:

      You are adding the LDAP configuration at the bottom of the LocalSettings.php file right?

      • DGseam says:

        Yes, the tail of my LocalSettings.php is as follows:
        (note I’ve tried varied configurations for array settings of AD – below represents the latest..)

        $wgLDAPDebug = 3;
        $wgDebugLogGroups["ldap"] = “/tmp/debug.log” ;
        require_once( “$IP/extensions/LdapAuthentication/LdapAuthentication.php” );
        $wgAuth = new LdapAuthenticationPlugin();
        $wgLDAPDomainNames = array( “STI”,”seamlessti” );
        $wgLDAPServerNames = array( “STI” => “EXCHANGE07.seamlessti.com”, “seamlessti”=>”exchange07.seamlessti.com” );
        $wgLDAPSearchStrings = array( “STI” => “STI\\USER-NAME”, “seamlessti”=>”STI\\USER-NAME” );
        $wgLDAPEncryptionType = array( “STI” => “ssl”, “seamlessti”=> “ssl” );
        ?>

        • Ryan Lane says:

          Essentially, PHP is telling you that it can’t find the AuthPlugin class, that is defined in MediaWiki core. Is this a fresh installation of MediaWiki? Is it one that has been upgraded? If you upgraded, did you simply copy over your old directory?

          Your problem seems to be unrelated to the LDAP plugin (unfortunately). Is everything else working properly with MediaWiki?

          BTW, you don’t need ?> at the end of your LocalSettings.php file anymore.

          • D Sherwood says:

            I was running into the same problem with “Cannot inherit from undefined class authplugin” messages. LdapAuthentication 1.2b , mediawiki 1.6.12 , php 4.3.9-3.29

            I got around the problem by adding “require_once( “includes/AuthPlugin.php” ); ” to LocalSettings.php . I’m not sure why I needed to manually include that, since it should be getting included in Setup.php, but once I added that everything started working.

          • Ryan Lane says:

            MediaWiki 1.6? PHP 4? Wow. Is everyone that is experiencing that problem on that version of MediaWiki? That may be the problem. I haven’t tested the plugin in MediaWiki 1.6 in years. I’m surprised and impressed it works :).

  8. helpdesk says:

    We have tried everything to get the authenticationof our wiki working against AD. I used your plugin but we ALWAYS get “wrong password” message. The wiki is running on a windows2003 server as a member server in our domain. We use xampp for our website.
    What could be wrong ?

    Below is our config :

    require_once( “$IP/extensions/LdapAuthentication/LdapAuthentication.php” );
    $wgAuth = new LdapAuthenticationPlugin();

    $wgLDAPDomainNames = array( “DOMAIN” );
    $wgLDAPServerNames = array( “DOMAIN” => “server001.domian.com server010.domian.som” );
    $wgLDAPSearchStrings = array( “DOMAIN” => “DOMAIN\\USER-NAME” );
    $wgLDAPEncryptionType = array( “DOMAIN” => “ssl” );

    //Allow the use of the local database as well as the LDAP database.
    //Good for transitional purposes.
    //Default: false
    $wgLDAPUseLocal = true;

    //Don’t automatically create an account for a user if the account exists in LDAP
    //but not in MediaWiki.
    //Default: false.
    $wgLDAPDisableAutoCreate = array(
    “DOMAIN”=>false
    );

    //Shortest password a user is allowed to login using. Notice that 1 is the minimum so that
    //when using a local domain, local users cannot login as domain users (as domain user’s
    //passwords are not stored)
    //Default: 0
    $wgMinimalPasswordLength = 1;

  9. RM says:

    I am stuck at the step where we have to find the AD’s cert.

    root@mediawiki:~# openssl s_client -connect myserver.test.name:636
    CONNECTED(00000003)
    4567:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:188:

    I get the same error at port 389.
    I have googled it high and low but am unable to solve the problem.

    BTW, my mediawiki is a Turnkey Linux appliance VM (Ubuntu-based)

    Someone please help me!

    • RM says:

      Well I found out the issue.

      1. our AD is not using SSL (AFAIK by default AD does NOT use SSL) so this line is changed to :

      $wgLDAPEncryptionType = array( “ASPDEV” => “clear” );

      2. You need to fully qualify the user-name; like this:

      $wgLDAPSearchStrings = array( “ASPDEV” => “USER-NAME@test.name” );

      After these two changes, I am in !

      One comment though…..it should give a “successfully logged in” type message. Instead, it returns to the login page…….making users think that the logon was not successful.

      But at the top right corner of the page we can see the “log out” button.

      Thanks for this plugin !

  10. RM says:

    pl ignore my last paragraph….now mediawiki is going to the “main page” after successful authentication. I guess that is OK too (instead of the “successful login ” message.

  11. Ranjan says:

    HI,

    I have authenticated my WIKI site with the LDAP authencation. Instead of domain name i used the IP address of the system. i had created two users and login to the site succefully. but the problem was next time when i want to login to my wiki site I am not able to login. When I created another new user, again i am able to login but only one time. Please help.

    • Ryan Lane says:

      That seems like a strange issue. I’ll need you to post your configuration, and debug info with sensitive stuff snipped out.

      • Ranjan says:

        Thanks Ryan for the reply. we are using Server 2003 & IIS 6.0. here is the configuration for LDAP authencation:

        require_once( “D:\WIKi/LdapAuthentication/LdapAuthentication.php” );
        $wgAuth = new LdapAuthenticationPlugin();

        $wgLDAPDomainNames = array( “***.***.***.***” )

        $wgLDAPSearchStrings = array( “***.**.***.***” => “Administrator@”***.**.***.***”" );

        I am using the Server IP address instead of Domain name. I have not configured the SSL & Certificate service.

        Please let me know if you need any further information.

        • Ryan Lane says:

          You should always use the FQDN of the server whether you have an ssl certain or not. Also, I don’t think user@ip-address will work for binding to AD. It expects to see user@domain.

          $wgLDAPDomainNames isn’t the right option to define your server. It is used for other config options and is what the end-user sees in the drop down box when logging in. $wgLDAPServerNames is the right option for that.

  12. Ranjan says:

    Hi Ryan Thanks for the reply. I changed to the FQDN of my Server. but still i am getting the above errors. Please let me know if i have to change somethning else.

    • Ryan Lane says:

      Your confguration should look like this:

      require_once( "$IP/extensions/LdapAuthentication.php" );
      $wgAuth = new LdapAuthenticationPlugin();
      
      $wgLDAPDomainNames = array( “MYDOMAIN” );
      
      $wgLDAPServerNames = array( "MYDOMAIN" => "mydomain.example.com" );
      
      $wgLDAPSearchStrings = array( “MYDOMAIN” => “USER-NAME@MYDOMAIN.EXAMPLE.COM" );
      

      Note in the above section that USER-NAME is a special string and shouldn’t be changed.

  13. RM says:

    I posted earlier here and I was successful in getting this working on one server.

    Today when I created another server and installed the same version of Mediawiki and this LDAP extension, with the exact same LocalSettings.php file……….it is not working !

    This is very strange.

    Where do I start troubleshooting?
    Is there a logfile something to look for?

  14. AH says:

    I am new to this so excuse me if its a dumb question but I can’t bind as the user, I’ve included the debug below

    Entering validDomain
    User is using a valid domain.
    Setting domain as: *
    Entering getCanonicalName
    Username isn’t empty.
    Munged username: *
    Entering authenticate

    Entering Connect
    Using SSL
    Using servers: ldaps://**.**.**.**
    Connected successfully
    Entering getSearchString
    Doing a straight bind
    userdn is: ***

    Binding as the user
    Failed to bind as ***
    Entering strict.
    Returning true in strict().
    Entering allowPasswordChange
    Entering modifyUITemplate

    • Ryan Lane says:

      You snipped out a little too much sensitive information :). I can’t see what the format of the username is. Also, you should post your configuration, since it is difficult for me to figure out how you configured the plugin just looking at the debug output.

  15. Charles says:

    Hi,

    I’ve got some difficulties to get work fine ldap extension.

    I downloaded the dll 1.2a from mediawiki, put it in my extension/LDAP directory, and put into LocalSettings.php this :

    require_once( “$IP/extensions/LDAP/LdapAuthentication.php” );
    $wgAuth = new LdapAuthenticationPlugin();
    $wgLDAPDomainNames = array( “BDDF-LDAP” );
    $wgLDAPServerNames = array( “BDDF-LDAP” => “directory.echonet” );
    $wgLDAPEncryptionType = array( “BDDF-LDAP” => “clear” );
    $wgLDAPSearchStrings = array( “BDDF-LDAP” => “uid=user_bddf,ou=FR,ou=EUROPE,o=GROUP” );
    #$wgLDAPSearchAttributes = array( “testLDAPdomain” => “uid” );
    #$wgLDAPBaseDNs = array( “BDDF-LDAP” => “dc=directory,dc=echonet” );
    #$wgLDAPGroupBaseDNs = array( “BDDF-LDAP” => “ou=EUROPE,o=GROUP” );
    #$wgLDAPUserBaseDNs = array( “BDDF-LDAP” => “ou=FR,ou=EUROPE,o=GROUP” );
    $wgLDAPUseLocal = true;
    $wgMinimalPasswordLength = 1;
    $wgLDAPDebug = 3; // 3 is a lot

    I know just little things about my ldap server : adress, o & ou, and the user connection for browse the ldap.

    I do not have encryption.

    I don’t understand why i can’t authentify myself on the ldap. The only error i have is “Bad password”, but i don’t know if i arrive to the ldap server !

    Thanks you very much for your help ;)

    Charles

    • Charles says:

      Hi,

      I tried this :

      $wgAuth = new LdapAuthenticationPlugin();
      $wgLDAPDomainNames = array( “ldap” );
      $wgLDAPServerNames = array( “ldap” => “directory.echonet” );
      $wgLDAPEncryptionType = array( “ldap” => “clear” );
      $wgLDAPSearchStrings = array( “ldap” => “cn=uid”, “ou=EUROPE”,”ou=GROUP”, “ou=FR” );
      $wgLDAPSearchAttributes = array( “ldap” => “uid” );
      //$wgLDAPBaseDNs = array( “ldap” => “ou=EUROPE,ou=GROUPE,ou=FR” );
      $wgLDAPBaseDNs = array( “ldap” => “dc=directory.echonet” );
      //$wgLDAPGroupBaseDNs = array( “ldap” => “ou=EUROPE,o=GROUP” );
      //$wgLDAPUserBaseDNs = array( “ldap” => “ou=FR,ou=EUROPE,o=GROUP” );
      $wgLDAPUseLocal = true;
      $wgLDAPAddLDAPUsers = false;
      $wgLDAPUpdateLDAP = false;
      $wgMinimalPasswordLength = 1;
      $wgLDAPDebug = 3; // 3 is a lot
      $wgShowExceptionDetails = true;

      But the only thing i had is the debug log is :
      LoginForm::attemptAutoCreate: $wgAuth->authenticate() returned false, aborting

      • Charles says:

        It works !!!

        require_once( “$IP/extensions/LDAP/LdapAuthentication.php” );
        $wgAuth = new LdapAuthenticationPlugin();
        $wgLDAPDomainNames = array( “ldap” );
        $wgLDAPServerNames = array( “ldap” => “directory.echonet” );
        $wgLDAPEncryptionType = array( “ldap” => “clear” );
        $wgLDAPSearchAttributes = array( “ldap” => “uid” );
        $wgLDAPBaseDNs = array( “ldap” => “ou=FR,ou=EUROPE,o=GROUP” );
        $wgLDAPUseLocal = true;
        $wgLDAPAddLDAPUsers = false;
        $wgLDAPUpdateLDAP = false;
        $wgMinimalPasswordLength = 1;
        $wgLDAPDebug = 1; // 3 is a lot
        $wgShowExceptionDetails = true;

        Thans a lot for the plugin ;)

  16. Bill says:

    You get nothing but calls for help, so I thought I’d throw you a “Thanks”.

    Worked great once I gave up on SSL and just used TLS. This is with an AD on Server 2003 and a windows client on the same domain. Not sure why that works, given your comment that “AD doesn’t support tls”. Shrug.

    Other than that, good stuff!

  17. LDAP configuration for use with Active Directory Domain Controllers running mediawiki on a windows server w/iis may require different settings than those indicated in the instructions on this site.
    Here are the settings that worked OK for us.

    require_once( “$IP/extensions/LdapAuthentication/LdapAuthentication.php” );
    $wgAuth = new LdapAuthenticationPlugin();

    $wgLDAPDomainNames = array( “xxx” );
    $wgLDAPServerNames = array( “xxx” => “server.xxx.local” );
    $wgLDAPSearchStrings = array(“xxx” => “xxx\\USER-NAME”);
    $wgLDAPEncryptionType = array( “xxx” => “tls” );

    In our case of AD, the ldap binds tls method by is what actually occurs between two windows servers by default when doing ldap over port 389. SSL did not function when configured as per instructions here (ldp.exe was able to connect and bind successfully; ldap plugin failed on both counts) Simple bind (clear) worked out of the box with no changes to AD configuration, which other than raising the domain to a 2003 level, is pretty much a default AD installation.
    I myself do not have time to do much more looking into this, but I think that using tls over port 389 was the way to go between ms ad and a member server running mediawiki and the plugin. I did verify the encryption using wireshark to view packets transferred between the two servers. simple bind was clear text, but tls encrypted the credentials. We also use an ssl cert on web servers that require non-anonymous authentication.

  18. Drew says:

    Trying to get this working using turnkey Mediawiki, but I don’t have /etc/openldap and I don’t see anywhere in the docs where you have to install it.

    Do you need openldap installed for this to work? I was under the impression you only need the extension.

    • Ryan Lane says:

      You need the openldap client libraries installed. I’d imagine that the openldap php extension would have had that as a dependency though. You definitely do not need the server package. Is this an Ubuntu distro, or a Fedora one?

  19. Thiago says:

    It works fine, but my AD doesn’t support LDAPS at this moment, so I have to use encryption type ‘clear’.
    Best Regards.
    Thiago

  20. Sebas says:

    Ryan,

    Im trying to install the 1.2b version because i need nested group support, but i get the following error:

    Warning: require(/srv/http/mediawiki/extensions/LdapAuthentication/LdapAuthentication.i18n.php): failed to open stream: No such file or directory in /srv/http/mediawiki/includes/MessageCache.php on line 808 Fatal error: require(): Failed opening required ‘/srv/http/mediawiki/extensions/LdapAuthentication/LdapAuthentication.i18n.php’ (include_path=’/srv/http/mediawiki:/srv/http/mediawiki/includes:/srv/http/mediawiki/languages:.:/usr/share/pear’) in /srv/http/mediawiki/includes/MessageCache.php on line 808

    Any idea’s?

    • Ryan Lane says:

      That is pretty strange. My extension doesn’t output any text to the user, so there is no reason it should be trying to load i18n… I’ll need to check with the internationalization folks to see what changed.

  21. Corey says:

    In case it helps troubleshoot….

    With the extension enabled, I get errors referring to the same line of MessageCache.php (808) whenever I try to access a special page, preferences, etc. Those pages simply show up blank. I’m running a fresh install of MediaWiki 1.15 with memcached enabled. The related error indicates “failed to open stream: No such file or directory in /includes/MessageCache.php on line 808″.

  22. David Miller says:

    Thank you for the great posting! I was able to get my XAMPP authenticating with active directory! I just want to note that setting the encryption type to clear was required for my setup to work. If I didn’t set the encryption type at all, the correct user and password combo would log me in, but the incorrect combo would throw a warning about TLS not being start- “Unable to start TLS”

    Thanks again!

  23. Mike says:

    Hello!

    I am getting the error, “Login error
    Incorrect password entered. Please try again.” When I try to log in and am banging my head against the wall as to why. I am using Active Directory as the LDAP server (unfortunately).

    My configuration in LocalSettings.php seems fine (domain names anonymized):

    require_once( “$IP/extensions/LdapAuthentication/LdapAuthentication.php” );
    $wgAuth = new LdapAuthenticationPlugin();
    $wgLDAPDomainNames = array( “MYADDOMAIN” );
    $wgLDAPServerNames = array( “MYADDOMAIN” => “dc1.mycompany.com” );
    $wgLDAPSearchStrings = array( “MYADDOMAIN” => “USER-NAME@MYADDOMAIN” );
    $wgLDAPEncryptionType = array( “MYADDOMAIN” => “ssl” );

    Also typing ldapsearch -Hldaps://dc1 -b “” -s base -x -W -D mike@myaddomain from the wiki server works and prints out all sorts of information on my LDAP server.

    Most peculiar is that when I watch traffic from the wiki server to the LDAP server while trying to log in, it seems the two servers aren’t talking:

    tcpdump -i eth0 -e -vv host 192.168.69.123 shows nothing when I’m logging in. Shouldn’t I see traffic to the LDAP server on 636 at this time?

    Can anyone out there give me a kick in the right direction on this? I’d sure appreciate it!

    Thanks,
    Mike

  24. Tobias says:

    After i click on the Logon button i become a HTTP 500 Internal Server error :(

    • Ryan Lane says:

      What shows up in your php logs? If you are getting a 500 error, then there is likely a crash. Without knowing what is crashing, I can’t help.

      • Mahesh says:

        Ryan,

        I receive the “HTTP 500 – Internal server error” since I edited the localsettings.php.

        One of your previous posts said this could due to crash. How can I check the logs.

        Thanks
        Mahesh

        • Ryan Lane says:

          You need to enable your php logs. See php’s documentation on how to do so.

          • Mahesh says:

            This is what I have done so far

            1. Donwloaded the LDAP plugin and placed it in the /extensions/Ldap Authentication.

            2. Created an account in AD, same account exists in Wiki datase with SYSOP access.

            3. Added the following to Local Settings.PHP

            require_once(“$IP/extensions/LdapAuthentication/LdapAuthentication.php” );
            $wgAuth = new LdapAuthenticationPlugin();
            $wgLDAPDomainNames = array( “DOMAIN” );
            $wgLDAPServerNames = array( “DOMAIN” => “dc01.domain.com dc02.domain.com”);
            $wgLDAPSearchStrings = array( “DOMAIN” => “USER-NAME@DOMAIN” );
            $wgLDAPEncryptionType = array( “DOMAIN” => “clear” );
            $wgLDAPGroupUseFullDN = array( “DOMAIN”=>true );
            $wgLDAPBaseDNs = array( “DOMAIN” => ‘dc=domain,dc=com’ );
            $wgLDAPSearchAttributes = array( “DOMAIN” => ’sAMAccountName’ );
            $wgLDAPGroupsUseMemberOf = array( “DOMAIN” => true );
            $wgLDAPGroupObjectclass = array( “DOMAIN”=>”group” );
            $wgLDAPGroupAttribute = array( “DOMAIN”=>”member” );
            $wgLDAPGroupNameAttribute = array( “DOMAIN”=>”cn” );
            $wgLDAPRequiredGroups = array( “DOMAIN”=> array( “cn=wiki-users,ou=groups,dc=domain,dc=com”));
            $wgLDAPUseLDAPGroups = array( “DOMAIN”=>true );
            $wgGroupPermissions['Wiki-users']['edit'] = true;
            $wgLDAPDebug = 3;
            $wgDebugLogGroups["ldap"] = “/tmp/debug.log” ;

            Please let me know what I have missed. I cannot find anything in the “tmp” logs folder.

          • Mahesh says:

            Ryan, can you help me with this. Need to know what I have done wrong here.

          • Ryan Lane says:

            The following directory shouldn’t be:

            /extensions/Ldap Authentication

            But, instead, should be be:

            /extensions/LdapAuthentication

            This may be the reason you are getting a 500 error.

  25. John says:

    My company uses a different port than 636 for the SSL LDAPS. Is there a place to change the port MediaWiki wants to use? This is on a MS platform.

    • Ryan Lane says:

      Ugh. I still haven’t added this option. On the rare occation someone asks, I always remember that. You’ll need to change it in the extension for now. Edit LdapAuthentication.php, search for 636, and replace it. I’ll try to remember to add this soon.

  26. Marcel says:

    Great plugin, got it installed with a minimum of fuss. Love the way I can control access via security groups. Our certificate system is pretty problematic here and I predictably encountered problems with validation. In the end, since the wiki is on an intranet anyway, I cheated and added ‘TLS_REQCERT never’ to ldap.conf

  27. Simon Eng says:

    LAPP on Centos 5.2 x64 authenticating against 2003R2 AD.

    Got the plugin working initially but now the Special Pages will not display unless I deactivate the plugin (I just get a blank page). Doesn’t matter whether I login locally with WikiSysop or with an assigned Bureaucrat or Admin through LDAP.

    I get this in the error log (even though I get a 200 in the access_log):

    [Tue Mar 30 15:49:31 2010] [error] [client 10.65.252.81] PHP Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 23040 bytes) in /opt/mediawiki-1.15.2/includes/IP.php on line 211, referer: http://10.65.4.191/mediawiki/index.php/Main_Page

    Tried restarting the service and also increasing the PHP script memory limit, but get the same results.

    If I deactivate the plugin, the Special Pages display correctly for WikiSysop.

  28. Martin von Herrmann says:

    I seem to be having the same problem Mahesh is having, and cannot get error logging to work.

    I have in my file, and that doesn’t work.

    $wgLDAPDebug = 3;
    $wgDebugLogGroups["ldap"] = “/home/admin/debug.log” ;

    I have tried a number of different paths, and none seem to work. Are there any other settings that could be interfering?

  29. Ajay Rungta says:

    I am trying to integrate LDAP Authentication with ConfirmAccount.

    A new user can request for an account. Once the user is approved by sysops, it send account request approval mail along with a temporary password (I guess local wiki DB password).

    Why is this password still generated when I am using LDAP authentication. How can I stop this password generation and sending temporary password to the user on approval?

    Any input on this will be very helpful? May be enabling or disabling some properyt… will keep on reading or looking for the same…

    Thanks

  30. Rolf says:

    I have tried to get it working, but it is failing on “Failed to bin”.

    Here is my output:
    Config:
    $wgLDAPDomainNames = array( “MYMGMT” );
    $wgLDAPServerNames = array( “MYMGMT” => “192.168.3.250″ );
    $wgLDAPEncryptionType = array( “MYMGMT” => “ssl” );
    $wgLDAPProxyAgent = array( “MYMGMT” => “cn=sa ldapepo,OU=service accounts,OU=gebruikers,DC=mymgmt,DC=local” );
    $wgLDAPProxyAgentPassword = array( “MYMGMT” => “*password*” );

    Debug:
    storage_wiki: Entering validDomain
    storage_wiki: User is using a valid domain.
    storage_wiki: Setting domain as: MYMGMT
    storage_wiki: Entering getCanonicalName
    storage_wiki: Username isn’t empty.
    storage_wiki: Munged username: myusername
    storage_wiki: Entering userExists
    storage_wiki:
    storage_wiki: Entering authenticate
    storage_wiki:
    storage_wiki: Entering Connect
    storage_wiki: Using SSL
    storage_wiki: Using servers: ldaps://192.168.3.250
    storage_wiki: Connected successfully
    storage_wiki: Entering getSearchString
    storage_wiki: Doing a proxy bind
    storage_wiki: Failed to bind as cn=sa ldapepo,OU=service accounts,OU=gebruikers,DC=mymgmt,DC=local
    storage_wiki: with password: *password*
    storage_wiki: Failed to bind
    storage_wiki: User DN is blank
    storage_wiki: Entering allowPasswordChange
    storage_wiki: Entering modifyUITemplate

    • Ryan Lane says:

      If you are using SSL, you need to use your server’s fully qualified domain name. IP addresses will not work, due to the nature of SSL. Also, your LDAP server must have an SSL certificate installed, and the CN field in the certificate must match the fully qualified domain name of the LDAP server. Your web server (the LDAP client), must also trust the CA certificate that signed your LDAP server’s certificate.

    • Ryan Lane says:

      Oh, you also need to specify more options to find users:

      $wgLDAPSearchAttributes = array(
      ‘MYMGMT’ => ‘sAMAccountName’
      );

      $wgLDAPBaseDNs = array(
      ‘MYMGMT’ => ‘OU=gebruikers,DC=mymgmt,DC=local’
      );

      • Rolf says:

        Hi Ryan,

        Thanks for your quick replay.

        For installing the SSL certificatie I did the following:
        openssl s_client -connect hmsvad002.mymgmt.local:636
        en copy the server certificate with out the begin and end header to:
        /etc/pki/tls/certs/hmsvad002.mymgmt.local.crt

        storage_wiki: Entering validDomain
        storage_wiki: User is using a valid domain.
        storage_wiki: Setting domain as: MYMGMT
        storage_wiki: Entering getCanonicalName
        storage_wiki: Username isn’t empty.
        storage_wiki: Munged username: myusername
        storage_wiki: Entering userExists
        storage_wiki:
        storage_wiki: Entering authenticate
        storage_wiki:
        storage_wiki: Entering Connect
        storage_wiki: Using SSL
        storage_wiki: Using servers: ldaps://hmsvad002.mymgmt.local
        storage_wiki: Connected successfully
        storage_wiki: Entering getSearchString
        storage_wiki: Doing a proxy bind
        storage_wiki: Failed to bind as cn=sa ldapepo,OU=service accounts,OU=gebruikers,DC=vcdmgmt,DC=local
        storage_wiki: with password: *password*
        storage_wiki: Failed to bind
        storage_wiki: User DN is blank
        storage_wiki: Entering allowPasswordChange
        storage_wiki: Entering modifyUITemplate

        Any idea where i can look at?

        • Rolf says:

          I found some more debugging:

          openssl s_client -state -nbio -connect hmsvad002.mymgmt.local:636 2>&1 | grep “^SSL”
          SSL_connect:before/connect initialization
          SSL_connect:SSLv2/v3 write client hello A
          SSL_connect:error in SSLv2/v3 read server hello A
          SSL_connect:error in SSLv3 read server hello A
          SSL_connect:error in SSLv3 read server hello A
          SSL_connect:SSLv3 read server hello A
          SSL_connect:SSLv3 read server certificate A
          SSL_connect:SSLv3 read server certificate request A
          SSL_connect:SSLv3 read server done A
          SSL_connect:SSLv3 write client certificate A
          SSL_connect:SSLv3 write client key exchange A
          SSL_connect:SSLv3 write change cipher spec A
          SSL_connect:SSLv3 write finished A
          SSL_connect:SSLv3 flush data
          SSL_connect:error in SSLv3 read finished A
          SSL_connect:SSLv3 read finished A
          SSL handshake has read 4757 bytes and written 315 bytes
          SSL-Session:

          SSL3 alert write:warning:close notify

        • Ryan Lane says:

          The certificate file must have the begin and end lines included!

          Also, is your ldap.conf file configured to point to that location? Notice if you are using fedora or RHEL, you have two ldap.conf files. /etc/ldap.conf, and /etc/openldap/ldap.conf. PHP uses the latter. The options you want to set in that file are the following:

          TLS_CACERTDIR /etc/pki/tls/certs
          TLS_CACERT /etc/pki/tls/certs/hmsvad002.mymgmt.local.crt

          Notice that the CACERTDIR directive assumes a hash-linked directory of files. TLS_CACERT points specifically to your file, and should work well. For more in depth info on this, see:

          http://www.mediawiki.org/wiki/Extension:LDAP_Authentication/Requirements#Certificate_trusts

  31. Ian says:

    Hi guys,

    I’m trying to get this going for our mediawiki that runs on ubuntu server.

    We run a Windows 2003 domain.

    I actually like trying to figure out problems myself as it’s how I learn best, but I am just running into brick walls.

    Basically what is happening is when I try and log in I am just getting a blank page.

    I CAN query the DC I am trying to get to using ldapsearch.

    When I have tried enabling debugging using:

    $wgLDAPDebug
    and

    $wgDebugLogGroups

    I have tried using debug levels 1 2 and 3.

    Using either option, nothing appears in the file specified with $wgDebugLogGroups

    Using 2 and 3 the following is displayed at the top left hand corner of media wiki after clicking the login button:

    Entering validDomain
    Uer is not using a valid domain
    Setting domain as: invaliddomain
    Entering modifyUITemplate

    However the login screen then doesn’t load properly and you can’t attempt to login (the login fields are missing).

    I am running MediaWiki 1.13.3
    LDAP Authentication PLugin is show as version 1.1g ( I installed using LdapAuthentication-MW1.13-r36354.tar.gz).
    Ubuntu is 9.04

    Can anyone point me in the correct direction as to how to troubleshoot this. Maybe let me know how to get some meaningful logs.

    Cheers

    Ian

    • Ryan Lane says:

      Nearly 100% of the time, a blank screen means the ldap library is missing in php. Run the following in ubuntu:

      sudo apt-get install -y php5-ldap
      sudo apache2 restart

      After doing so, try it again.

Leave a Comment