Forums / Developer / Placing users in a group based of LDAP attribute

Placing users in a group based of LDAP attribute

Author Message

Bruce Morrison

Thursday 18 March 2004 5:55:47 pm

I'm currently building an extranet application and am utilising the LDAP authentication. In particular I'm using the option that places an LDAP user in a user group based on a LDAP attribute.

I have the following the /override/ldap.ini.append.php file

# LDAP attribute type for user group. Could be name or id
LDAPUserGroupAttributeType=name
# LDAP attribute for user group. For example, employeetype. If specified, LDAP users
# will be saved under the same group as in LDAP server.
LDAPUserGroupAttribute=o

where o is the organisation.

In eZ Publish I have a User Group called 'Client A' and a Folder called 'Client A". When I login to the system with a user with an organisation of 'Client A' the eZ Publish user is being created under the Client A folder and not the user group.

Looking at the code in kernel/classes/datatypes/ezuser/ezldapuser.php I discovered that when LDAPUserGroupAttributeType is set to name all object that match that name are retrieved and the first matching node is used for placement. I want it to use the first matching node of type 'User Group'.

The code in question is

if ( $LDAPUserGroupAttributeType == "name" )
{
$groupName = $info[0][$LDAPUserGroupAttribute][0];
if ( $groupName != null )
{
$groupQuery = "SELECT ezcontentobject_tree.node_id
FROM ezcontentobject, ezcontentobject_tree
WHERE ezcontentobject.name='$groupName'
AND ezcontentobject.id=ezcontentobject_tree.contentobject_id";
$groupObject =& $db->arrayQuery( $groupQuery );

if ( count( $groupObject ) > 0 )
{
$defaultUserPlacement = $groupObject[0]['node_id'];
}
}
}

The quick n' dirty solution is add a where clause to the $groupQuery to only return items with a contentclass_id of 3 (User Groups)

$groupQuery = "SELECT ezcontentobject_tree.node_id
FROM ezcontentobject, ezcontentobject_tree
WHERE ezcontentobject.name='$groupName'
AND ezcontentobject.id=ezcontentobject_tree.contentobject_id
AND contentclass_id = 3";

I've never liked hard coding these things so a better solution would be to add an additional ini file variable that defines the content class that will be searched for a match.

Does anyone think that there is a need to allow for multiple content class id to be defined?

Thanks
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Jonny Bergkvist

Friday 19 March 2004 12:13:39 am

I am also using the LDAP-auth, and have experienced the same problem as you describe. To get around it, I chose to use id instead of name for matching:

LDAPUserGroupType=id
LDAPUserGroup=<object_id> (not node-id!)

(I have not started using the LDAP-attribute-functionality yet, but I soon will)

I do support your idea of being able to specify object-class! For my use, I cannot se the need for multiple content-class-ie's to search for, but I think the support for it should be there anyway to make it more flexible and general. It shouldn't be much more difficult to make.

The ini-variable could be an array like:
LDAPUserGroupClassFilters[]

Samuel Sauder

Thursday 19 May 2005 7:29:42 am

I have version 3.5.0 and it does include this id=3 logic.
I happened to stumble unto it from the /cronjobs/ldapusermanage.php side. We have an odd configuration for NDS that causes all the ldap_bind function calls not to work. So I'm trying to debug that ;)

eZ debug

Timing: Jan 19 2025 06:05:22
Script start
Timing: Jan 19 2025 06:05:22
Module start 'content'
Timing: Jan 19 2025 06:05:22
Module end 'content'
Timing: Jan 19 2025 06:05:22
Script end

Main resources:

Total runtime0.2011 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 590.5156180.8125
Module start 'content' 0.00550.0055 771.328197.9297
Module end 'content' 0.01100.1901 869.2578533.3750
Script end 0.2011  1,402.6328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00331.6234200.0002
Check MTime0.00130.6296200.0001
Mysql Total
Database connection0.00080.415110.0008
Mysqli_queries0.157078.08281410.0011
Looping result0.00120.60171390.0000
Template Total0.189794.310.1897
Template load0.00090.464910.0009
Template processing0.188893.850210.1888
Override
Cache load0.00060.313210.0006
Sytem overhead
Fetch class attribute can translate value0.00080.405210.0008
XML
Image XML parsing0.00030.158610.0003
General
dbfile0.00522.5908200.0003
String conversion0.00000.002530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs