Active Directory LDAP Authentication - seems to work, but still a problem

edited March 2010 in Plugins
I've configured the LdapAuthentication plugin in my config.php file (I'll paste in a sanitized version of it below) but I'm having a weird issue whenever I login as an AD user. I've confirmed with the AD admins that they're seeing successful login attempts on their end, but what happens on my install of Status.net is that as soon as I click the Login button, a blank page loads, with the address bar still showing /main/login. In addition, the user doesn't actually seem to be logged in at all, at least not as far as Status.net is concerned.

Any thoughts?

Here is the LDAP section from my config.php

addPlugin('ldapAuthentication', array(
'provider_name'=>'AD-new',
'authoritative'=>false,
'autoregistration'=>true,
'binddn'=>'serviceaccount',
'bindpw'=>'sapassword',
'basedn'=>'DC=child,DC=domain,DC=edu',
'host'=>array('first.domain.controller', 'second.domain.controller'),
'password_encoding'=>'ad',
'attributes'=>array(
'username'=>'sAMAccountName',
'nickname'=>'sAMAccountName',
'email'=>'mail',
'fullname'=>'displayName',
'password'=>'unicodePwd')
));

Comments

  • edited March 2010
    there is a bug with 'ad' i belive set password changeable to false (details in the ldap readme)

    blank page on login you say? nothing in the logs?
    are your ldap user names valid statusnet usernames? [a-z 0-9]
  • I will try changing that setting.

    And yes, blank page on login, seemingly without successfully logging in, at least as far as the app is concerned. On the AD side, it looks like a successful login was made.

    Now this may be where I'm going wrong, I thought that if I had autoregistration set to true, that statusnet user accounts would be created at initial login via LDAP?

    Just for testing, I created a statusnet account with the same username and password as an AD test user, and I get the same blank page result.
  • Oh, and yes, all the ldap usernames I'm using for testing contain only a-z, 0-9.
  • Set password_changeable to false, and I'm getting the same behavior.

    Is there a way to turn on any sort of debug logging? I'm not sure which logs you're asking about, but I'll take a look at them if you can point me in that direction.

    Thanks!
  • Ok, I checked apache's error_log and I do see this, which I'm hoping will help narrow things down:

    PHP Fatal error: Call to a member function search() on a non-object in /var/www/html/statusnet/plugins/LdapAuthentication/LdapAuthenticationPlugin.php on line 212
  • edited March 2010
    You are correct that auto-register should do just that.
    Hmmm, ill have to get back to you on this one. I dont think we have done enough testing on AD, only open-ldap...



    //---utility functions---//
    function ldap_get_config(){
    $config = array();
    $keys = array('host','port','version','starttls','binddn','bindpw','basedn','options','filter','scope');
    foreach($keys as $key){
    $value = $this->$key;
    if($value!==null){
    $config[$key]=$value;
    }
    }
    this is line 212 --> return $config;
    }

  • Hrmm, what you pasted in there is higher in the file than mine. Here is what I have around line 212, with the search function itself on line 212.

    function ldap_get_user($username,$attributes=array(),$ldap=null){
    if($ldap==null) {
    $ldap = $this->ldap_get_connection();
    }
    $filter = Net_LDAP2_Filter::create($this->attributes['username'], 'equals', $username);
    $options = array(
    'attributes' => $attributes
    );
    $search = $ldap->search($this->basedn, $filter, $options);

    if (PEAR::isError($search)) {
    common_log(LOG_WARNING, 'Error while getting DN for user: '.$search->getMessage());
    return false;
    }
  • @mikestanley sounds like we are running different versions?
    which version is yours?

    0.9.1 just came out, I might try that to start.

    though there may actually just be some bugs in AD, I wish I had a setup I could test on.

  • edited March 2010
    @candrews wrote this plugin, here's his take on the issue.

    candrews: Hmm, the line numbers don't match with 0.9.1
    foucault: yeah...
    foucault: okay lets leave it at "time to upgrade" :)
    candrews:http://gitorious.org/statusnet/mainline/blobs/980d1a66ec0bb5b42ddb39e253fba9bad1b41aca/plugins/LdapAuthentication/LdapAuthenticationPlugin.php#line212
    There's the line where he gets an error
    so $ldap isn't defined at that point....
    I re-did how this works for 0.9.1 - so I bet that whatever issue he has is probably solved in that version.
  • Hey folks, I'm trying to do the same and I'm getting the blank page too after entering my credentials. Has anyone come up with a reliable solution yet?
  • @mick please provide more information, like log files, version, hosting enviroment
  • @mick, I also recently had an issue with 0.9.1 returning a blank page when I was trying to login through LDAP... in my case it was largely an issue with being unfamilar with PHP. I had installed PHP on IIS7 without including the LDAP module. After installing the LDAP module in PHP the LDAP authentication plugin started working. Just thought I would toss that out there, just in case...

    @mikestanley, I also ran into an issue not entirely dissimilar to the one you reported... in that case I was connecting to a parent level domain to validate a child level domain user, for example:

    --> company.corp
    --> -->na.company.corp
    --> --> --> Users
    --> --> --> --> Bob T. User

    My config pointed to company.corp and I could query for that user using an LDAP browser. However I got an error similar to yours from Status.Net. When I reconfigured my app to point to na.company.corp it worked great. Again, this may be something completely unrelated to what you are working on, but I thought I would offer it in case it helps.
  • @joeliedtke @aric I too am trying to get the LDAP plugin to work. I'm running v0.9.1 on a wamp server with PHP 5.2.11. I was getting a blank screen as well on using my ldap credentials. I installed the php ldap module and now it takes about 20 seconds to get the blank screen :)

    Here is my config for the statusnet LDAP plugin:

    addPlugin('ldapAuthentication', array(
    'provider_name'=>'somecompany',
    'authoritative'=>true,
    'autoregistration'=>true,
    'password_changeable'=>false,
    'email_changeable'=>false,
    'binddn'=>'admin@somecompany.com',
    'bindpw'=>'password',
    'basedn'=>'DC=somecompany,DC=com',
    'host'=>array('10.xxx.xx.xx'),
    //'password_encoding'=>'ad',
    //'scope'=>'sub',
    'attributes'=>array(
    'username'=>'sAMAccountName',
    'nickname'=>'sAMAccountName',
    'email'=>'mail',
    // 'password'=>'unicodePwd'
    'fullname'=>'name')
    ));

    I have used 'name' since the displayName contained special characters and I read a post somewhere saying it could be a problem. The 'name' field contains a-zA-Z characters only.

    I cannot find any errors related to ldap in the apache/php logs... am I missing any other ones?

    I am able to browse the ldap director using a standalone ldap browser and the correct binddn/bindpw/basedn/host.

    Can someone kindly help me out?
  • edited April 2010
    btw... I tried playing around with the config...commenting/uncommenting certain lines..
    uncommenting //'password_encoding'=>'ad' and //'scope'=>'sub' doesn't help
    'fullname'=>'displayName' or 'fullname'=>'sAMAccountName' doesn't work either
    still get the blank screen after a while...

    the only error i get in the apache log on trying to log in is:
    File does not exist: D:/wamp/www/favicon.ico
  • @joeliedtke Thanks for your comments however I have already installed the PHP LDAP module (after trying a few times without it installed) it's still giving me jip though. If I make minor changes to the BINDN i.e change admin to admin@domain.com I get an error saying that the credentials are invalid. I'm coming to the end of me tether with this error!
  • @flash4484 - I'm no expert, but having recently worked on getting this to work with my site this it sounds like something may be timing out... I'd recommend uncommenting the password_encoding config, reformatting your binddn to either be the user's samaccountname or DN, and trying setting the basedn to be the DN that your users are in. [For example:OU=users,OU=na,DC=somecompany,DC=corp] Those are the only major differences I see between my site's LDAP auth config and yours.
  • I setup LDAP and after logging in it gives me the following error:

    An important error occured, probably related to email setup. Check logfiles for more info..

    I used different accounts that are all email enabled but still get the same error.

    Here is my configuration....

    addPlugin('ldapAuthentication', array(
    'provider_name'=>'domain',
    'authoritative'=>true,
    'autoregistration'=>true,
    'password_changeable'=>false,
    'email_changeable'=>false,
    'binddn'=>'CN="LDAP User",CN="Users",DC="domain",DC="gr"',
    'bindpw'=>'password',
    'basedn'=>'OU=Users,OU=Corporate,DC=domain,DC=gr',
    'host'=>array('srv1.domain.gr', 'srv2.domain.gr'),
    'password_encoding'=>'ad',
    'attributes'=>array(
    'username'=>'sAMAccountName',
    'nickname'=>'sAMAccountName',
    'email'=>'mail',
    'fullname'=>'displayName',
    'password'=>'unicodePwd')
    ));

    Can someone help please?
  • It's hard to help with all this, as there can be so many differences in an ldap setup. I think what I will do is get the plugin to output lots more debugging so we can track down exactly what is going on for each case.
  • Thank you for this. How do we enable logging at the moment and where are the logfiles located?
  • @karasardelis this extra logging is not written into the plugin yet.
    I'll report here when it is.
  • I thought I'd add this working ldap configuration to this conversation. This works for an AS/400 LDAP server. Note the version is 2 instead of 3 and there are no binding credentials.

    addPlugin('ldapAuthentication', array(
    'provider_name'=>'ldap',
    'authoritative'=>true,
    'autoregistration'=>true,
    'password_changeable'=>false,
    'email_changeable'=>false,
    'version'=>'2',
    'basedn'=>'dc=somesubdomain,dc=somehostname,dc=com',
    'host'=>array('somehostname.com'),
    'attributes'=>array(
    'username'=>'uid',
    'nickname'=>'uid',
    'email'=>'mail',
    'fullname'=>'description')
    ));


  • @joeliedtke your idea to enable LDAP in the php.ini worked for me.
    Uncomment the line: extension=php_ldap.dll
    I installed PHP using XAMPP for the record. And I was getting the blank page after attempted login.
  • Having an issue with LDAP,

    The error is;
    Could not connect to LDAP server: Bind failed: Inappropriate authentication: LDAP_INAPPROPRIATE_AUTH

    addPlugin('ldapAuthentication', array(
    'provider_name'=>'ldap',
    'authoritative'=>true,
    'autoregistration'=>true,
    'password_changeable'=>false,
    'binddn'=>'ou=ZIV0,ou=Applications,dc=fg,dc=rbc,dc=com',
    'bindpw'=>'xxxx',
    'basedn'=>'Ou=People,dc=fg,dc=rbc,dc=com',
    'host'=>'globdev.saifg.rbc.com',
    'scope'=>'sub',
    'attributes'=>array(
    'username'=>'employeeNumber',
    'nickname'=>'employeeNumber',
    'email'=>'mail',
    'fullname'=>'displayName',
    )));
  • It has to do with how you're authenticating to the bind server, you may need to specify a different auth scheme depending on your bind sever. This is the description for that error: Inappropriate authentication was specified (for example, LDAP_AUTH_SIMPLE was specified and the entry does not have a userPassword attribute)
  • Are there any common examples of different auth scheme, limited LDAP experience and I'm not sure how to specify anything different than what's already listed above?
  • Unfortunately I don't have that much LDAP experience myself, you can check out the docs for the pear php LDAP package that the plugin uses, it may provide some insight. http://pear.php.net/manual/en/package.networking.net-ldap2.php
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID