![]() |
LDAP Authentication
1 Attachment(s)
I've only recently started using vBulletin, and this is my first mod so if you use this, please click Installed!
This mod (which builds on the fine work from malcomx and zemic) is intended to lower the barriers to using and LDAP directory as an external authentication source for your board. The idea is simple; capture a login attempt before authentication and test it against LDAP first, if that succeeds, see if there is already a matching user in vBulletin. If there is not, create one, using data from the LDAP to fill in the required fields, if there is already a matching user (Determined by comparing email addresses) then update the user. You might be asking why this mod is better than the two mods I've mentioned above? Well firstly the only additional file is the XML file for the new hooks (See below), and no changes to vBulletin code so installation is simple, and upgrades to vBulletin don't get over complicated by re-applying changes. Secondly, all the settings are controlled from the admincp rather than an external config file. Thirdly (as if two wasn't enough) I've added some hook points so this mod can be extended, for example to get additional data from the LDAP and put it in user profile fields. One important similarity with the two earlier mods is that in the admincp and modcp no LDAP authentication is performed, this is a safety feature, so even if the mod or an extending to it, breaks your board, you shouldn't ever get locked out of the admincp so you'll be able to turn if off quickly. Additional Hooks The mod is essentially a single plugin (plus options and help) which runs at global_complete which is before most other things have happened, but just after all the global setup has occurred. To enable the additional hooks, you need to upload the file hooks_ldap_auth.xml to /includes/xml under your forum. The following new hooks are created by this mod:
By requesting new attributes at ldap_auth_start and then applying them at either ldap_auth_all_user, ldap_auth_new_user or ldap_auth_existing_user you can setup your users easily without having to write all the LDAP code yourself! AdminCP Settings This mod creates a new options group called LDAP Authentication between email options and user registration options where you set the host name and port number of the LDAP server, the initial authentication type (Anonymous or authenticated), optionally the BindDN and Password for the LDAP server. You also set which attribute matches the vBulletin username (The default is cn which works well for inetOrgPerson based entries). You can set additional attributes to retrieve (If you want to quickly knock up a simple plugin which uses them at one of the hook points above). There is also the facility to disable (or rather make unavailable) accounts which exist in vBulletin but not in LDAP. Given that your initial admin may fall into this group, there is also a list of userids who should be allowed to log in anyway. Requirements
I'll try to provide support to users of my mod, but please bear in mind I fairly new to all this, so I may not be able to solve all problems immediately. Support will only be provided via this thread (Don't PM or email me unless I ask you to). Priority will be given to users who have clicked Installed. Release Notes
Installation
Haqa... |
Ok, so how do you use the hooks to make a mod which can use and extend ldap_auth?
Roughly like this:
There are, of course, many other things you could choose to do in your plugin, for example if you call the standard_error function, you'll display a nice error message page (For example if the user has a flag denoting the account is disabled) HOWEVER you need to call process_logout() first as the user will be partly logged in (If their account already exists in vBulletin). Examples of this can be found in the LDAP Authentication plugin in this mod, or in the Full Name Support for LDAP Auth and Location Support for LDAP Auth mods (Coming soon). Hope this helps Haqa... |
---
|
Quote:
Good luck with your exam! H. |
---
|
You should use TABLE_PREFIX for vbulletin :-)
|
Great to see this addon and I have one single question as of now: What if I use this with an empty directory? Does this addon automatically inserts the users to the LDAP?
|
Quote:
Quote:
There are a number of good tools for LDAP management, I use yala, though this does open a potential security hole unless you are VERY careful (It exposes your LDAP to the internet via the web). H. |
Quote:
|
Nice hack, planning on using this in the future to have only one userdatabase :)
|
Quote:
H. |
---
|
Quote:
The other point is that I'm trying to make my mods so that they don't break upgradability of VB (or any other products). Anyone else know of a simpler way to do Windows SSO? H. |
Quote:
You'd still need some fairly significant mods to vB, (or perhaps a plug somewhere near global_start???) to tell it to use and trust the external username supplied by SPNEGO. H. |
Very nice mod - installed with no fuss.
I though had the problem that my LDAP server was containing a new user where the username was not used in vB, but the email was already taken by another username in vB. This means that your plugin tries to create the new user when a correct username/password is issued (seen from the LDAP server). But due to that the email already exists i vB with another username then the creation of the new user fails. This is properly okay, as two different users can not have the same email. But the error messages indicates that a wrong password/username is issued. My suggestion for improvement is to give better response to this case. Best regards Tom |
Quote:
I'll have to look into this bug, that's NOT what's meant to happen - It's supposed to rename the user to match the LDAP... I can see what you mean though, the error message is unhelpful in this instance, but in keeping with normal login failure message procedure, I've tried not to allow a potential brute-force attacker know what he/she got wrong (username/password etc). A more "helpful" error message might give away the fact that users are being created on the fly from an external database, and that might give an opportunity to inject a user into the system. (Sorry if I seem paranoid, but it's my job, I work with system security all day). H. |
The plugin is populating vB's db properly when an exisiting LDAP user tries to login to the forums but doesn't exist in vB; however, it won't log them in -- stating they have entered an incorrect password. The samething happens for existing vB users.
The passwords are stored as an MD5 hash in LDAP, and I also made sure define('DISABLE_PASSWORD_CLEARING', 1); was in includes/config.php. The stange thing is, if I disable the plugin both exisiting and newly created users (from LDAP) can successfully login. Any ideas on what might be causing this? |
I have installed this plugin, but cant get it to work. Has anyone gotten this plugin to work in an active directory environment. thank for your help.
|
Quote:
|
didn't you mix up your hooks in product-ldap_auth-1.4.xml? your ldap_auth_existing_user is called when you're creating a fresh user, while ldap_auth_new_user is called when the user has been found in forum... am i confused??
|
Hy
I installed the plugin, but i get several errors or strange behaviours: 1) I can't login with an admin account 2) I get always following error at the login with an other user: Quote:
Anyone an idea? thanks in advance |
Quote:
Quote:
Quote:
Quote:
Quote:
Certainly though, failing to log into MySQL would prevent anyone logging in... Is the site sending you database error emails? H. |
Hi, does this work with vB 3.8.x and/or 3.7.5?
Thanks A |
Hi,
I have installed the plugin on a vB 3.7.5 following the above instruction. I then created a new user usingthe forum registration and that user was not added in LDAP. what did i do wrong? is it possible to get users added on ldap upon registration from the forum? Thanks Antonio |
I am not using this plugin, however I developed a different product to help me use a different login source than ldap, and I used this as a base. I noticed that the hook global_complete is called AFTER login logic takes place, this seems to be counter to how the hook is designed. This might be causing some of the issues people are seeing. I modified my plugin to use global_setup_complete instead. Note, using this approach requires a bit more setup logic to be used.
|
Quote:
Quote:
Quote:
I'll have to revisit the code. H. |
Quote:
Sorry. H. |
Haqa,
I've been trying to get the plugin running with vb 3.8.1. I noticed that the gobal_complete hook isn't called on a login. I'm just learning the hooks but do I need to change that the plugin to fire on global_setup_complete? Thanks, Anthony |
Quote:
H. |
Quote:
Also, I had a problem with DISABLE_PASSWORD_CLEARING. I traced it back to line 598 of global.php. I had to switched the 1 and 0 on that line so $show['nopasswordempty'] would get the right value. -Anthony |
any updates on how to get this working with Active Directory? Additionally I would like to use it without anonymous query access...for other apps that authenticate with Active Directory I have a specific user for that...
|
Quote:
You should find the it will work, but you need to set the correct Naming Attribute, can't remember what it needs to be of the top of my head, but and LDAP browser should be able to connect and you should see which entry you want. H. |
1 Attachment(s)
Hi Haqa,
I'm using your LDAP add-on (version 1.5) on my vBulletin 3.8.1 Patch Level 1. I'm a new to LDAP, I tried a lot of times, but still could not get the parameters right. Attachment is my configuration, would you please teach me what's wrong with my parameters? Thank you! |
Quote:
I'm working on a new, 3.8 compatible version (Which therefore will probably NOT work on 3.7) but due to work commitments it's not going as quickly as I would like. H. |
Quote:
Thank you for your generous reply, I just get the vBulletin 3.7.6 and tried again, no matter I configured as the picture you posted, or as the picture I posted, it still doesn't work. Can you explain me the exact meaning of the fields "Naming Attribute", "Search Base DN" and "LDAP Attributes"? And can these fields be blank? Thank you! |
Quote:
Firstly LDAP is a hierarchical database, that is it is structured like a file system with branches (Think directory) and leaves (Think file). Each node, either branch or leaf has a Distingushed Name (DN) which is made up of the Naming Attribute followed by the DN of the node in which it sits so if you have a branch of your tree called:- dc=example,dc=com And the naming attribute for an inetOrgPerson class is CN then an inetOrgPerson with CN=fred would have the DN of:- cn=fred,dc=example,dc=com The search base is the point in the tree to start searching from. Think of it like this, if on a windows machine you are searching for a document, you don't want to search the entire hard disk, you might start searching in "C:\Documents and Settings" to limit the time taken to find the file. This is what the search base does, so in my example above, to find fred I might set the search base to:- dc=example,dc=com The Additional LDAP Attributes setting is to support my add-on products, like Location Support and Fullname Support. For them to work you need to put the attribute name here so that the LDAP Authentication module pulls out the data needed by the add-on modules. If you are not using any modules which extend LDAP Authentication then you don't need to put anything there. While I'm at it, don't forget that some AD servers don't support what's known as Simple Bind (Which is all that standard PHP can do) but instead need a different sort of login called Kerberos. If your Windows Server is configured to only support Native authentication then there is a good chance that PHP won't be able to bind (Login) and my module just won't work at all. I'm afraid there is nothing I can do about that, it's simply not possible with the standard version of PHP. I hope this makes a rather complex and confusing subject a little clearer. H. |
1 Attachment(s)
Haqa I'm having a heck of a time getting this to work with 3.8.2.
I know you don't have it certified to work with it yet but I've seen a few others mention that they got it working with their AD setups. The information in the screen shot is a copy and paste from a working LDAP tie in from a PHP/Tomcat application as well the PHPBB forums which I had running BEFORE I purchased VBulletin to switch over. When I activate the plug-in
I don't need to add users to the database, all I really need is VB to reach out, see that the user is there, see that their password is correct and then let them in. We're an educational institution with our own Active Directory structure and we just want to unify as much as possible around one account system. Side Note: If anyone has any information on where I can turn on advanced logging to see if there's additional information I can get out of the VB that would be awesome. |
Hi Haqa, with your so detailed explanation, I think I get a little understand LDAP.
But still, I could not get the authentication passed. I tried four times with different parameter groups, these parameters are not changed through my test: "LDAP Server" is set "172.29.128.29" (IP address of my AD server), "LDAP Port" is "389" (Default value), "Naming Attribute" is set "cn", "Search Base DN" is set "dc=test,dc=com" (My domain is test.com), "LDAP Attributes" is always blank, "Allow Built-in Accounts" is always set "1". The other fields in the four test groups are: 1. "Anonymous Bind" is set "Yes", "Bind DN" and "Bind Password" are set blank, "Disable vBulletin Users" is set "Yes" When I login with my domain account, it shows "You have entered an invalid username or password. ..." 2. "Anonymous Bind" is set "Yes", "Bind DN" and "Bind Password" are set blank, "Disable vBulletin Users" is set "No" When I login with my domain account, it shows "You have entered an invalid username or password. ..." 3. "Anonymous Bind" is set "No", "Bind DN" is set "Administrator" "Bind Password" is set password for account "Administrator" in domain "test.com", "Disable vBulletin Users" is set "Yes" When I login with my domain account, it shows "Failed to bind to LDAP directory (Initial bind)" 4. "Anonymous Bind" is set "No", "Bind DN" is set "Administrator" "Bind Password" is set password for account "Administrator" in domain "test.com", "Disable vBulletin Users" is set "No" When I login with my domain account, it shows "You have entered an invalid username or password. ..." Could you please tell me that did I get anything wrong for your program? Thank you! |
I think I figured my problem out.
Haqa, In your instructions you say to place the line below in to config.php //LDAP Access Control define('DISABLE_PASSWORD_CLEARING', 1); Did you mean to say global.php? Once I added it to global.php I was able to authenticate most of my users. I do believe there's a problem with users that have very long passwords. They're not able to log in. |
I got some PMs asking how I got Haqa's plugin working in 3.8.1 so here's what I did...
Start off by creating a hook in login.php and registering it by following the directions here: https://vborg.vbsupport.ru/showthread.php?t=148573 Do the edit to global.php mentioned in the directions above. I verified that the 1 and 0 for DISABLE_PASSWORD_CLEARING in global.php were swapped in 3.8.1. If you don't do that edit, vb will encrypt the user's password in an md5 hash onsubmit of the login form. Unless your AD passwords are stored in an md5 hash, the password check will fail. Install Haqa's plugin and go into the plugin manager and set it to fire on the new hook you created. I setup some logging in the plugin code so I could see what was going on. If you get this far, it's all configuration from there. I extracted the logging code from the plugin linked above to help me debug and added it to Haqa's plugin code: Code:
define('LDDEBUG', true); The only downside of this approach is that I had to edit vb source. This is only a temporary solution I hope. I just upgraded to 3.8.2 and saw that global.php and login.php were both overwritten... Hopefully Haqa comes up with a way do to all this without altering any vb source. Something else for people that are having trouble... vb uses your email as a primary key for users. Initially, my vb admin account was setup to use my email. When I went to test the plugin by using my username from AD to log in, the plugin code tried to create me a new account but failed because my email was already in use by the admin account. |
All times are GMT. The time now is 04:54 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|