David Ramsden
2016-09-26 10:49:49 UTC
Hello.
Wanted to feedback a hacked login_ldap.php to the community.
The attached replacement for login_ldap.php may break (read: probably will!
:)) anyone using OpenLDAP (I have no OpenLDAP environment to test against)
but should help those who like us have multiple AD domains where users of
OpenDCIM may be within one of those domains.
Even if you have a single AD domain this will still work for you. This
removes any dependancy on users/groups/whatever being in certain OUs which
can be fairly restrictive for OpenDCIM as well.
The OpenDCIM security groups need to be created within the root domain
(e.g. domain.local) but users can be within any OU within any sub-domain
(e.g. eu.domain.local, am.domain.local).
First create AD universal security groups in the root domain to match the
OpenDCIM permissions. For example:
OpenDCIM-SiteAdmin
OpenDCIM-ContactAdmin
OpenDCIM-SiteAccess
OpenDCIM-WriteAccess
OpenDCIM-ReadAccess
OpenDCIM-DeleteAccess
OpenDCIM-RackRequest
OpenDCIM-RackAdmin
OpenDCIM-BulkOperations
OpenDCIM-AdminOwnDevices
Then populate the groups with either individual users or groups that users
are a member of. e.g. add the Network Ops group to OpenDCIM-SiteAccess,
OpenDCIM-ReadAccess and OpenDCIM-AdminOwnDevices groups.
Edit the OpenDCIM configuration via the web interface and change the LDAP
parameters.
LDAP Server URI: Needs to point to a Global Catalog server in the root
domain (e.g. dc1.domain.local:3268)
Base DN: Should be the base DN for the root domain (e.g. dc=domain,dc=local)
Bind DN: Should be set to %userid%
User Search: Should be set to (|(userPrincipalName=%userid%))
Note: Base Search is no longer used and can be ignored.
Set the DN for the groups, e.g.:
Site Access: CN=OpenDCIM-SiteAccess,OU=OpenDCIM,OU=Security
Groups,DC=domain,DC=local
(if the OpenDCIM-SiteAccess group lives in domain.local/Security
Groups/OpenDCIM)
Replace login_ldap.php with the attached.
Now users should be able to login with their UPN (user principle name),
e.g. ***@eu.domain.local or whatever their UPN is set to in AD.
This modified version of login_ldap.php:
1. Attempts to authenticate the user against AD. If the user
authenticated...
2. Gets the groups the user is a member of.
3. Checks if the groups the user is a member of is a member of the
appropriate OpenDCIM group OR if the user itself is a member of the
appropriate OpenDCIM group.
Tested against 4.3 and 4.3.1 only.
Hopefully this is useful and maybe some of this could find its way in to a
future release. I'd suggest possibly another authentication method called
"AD" so that it decouples AD from LDAP and would make maintaining and
testing code easier.
Regards,
David.
Wanted to feedback a hacked login_ldap.php to the community.
The attached replacement for login_ldap.php may break (read: probably will!
:)) anyone using OpenLDAP (I have no OpenLDAP environment to test against)
but should help those who like us have multiple AD domains where users of
OpenDCIM may be within one of those domains.
Even if you have a single AD domain this will still work for you. This
removes any dependancy on users/groups/whatever being in certain OUs which
can be fairly restrictive for OpenDCIM as well.
The OpenDCIM security groups need to be created within the root domain
(e.g. domain.local) but users can be within any OU within any sub-domain
(e.g. eu.domain.local, am.domain.local).
First create AD universal security groups in the root domain to match the
OpenDCIM permissions. For example:
OpenDCIM-SiteAdmin
OpenDCIM-ContactAdmin
OpenDCIM-SiteAccess
OpenDCIM-WriteAccess
OpenDCIM-ReadAccess
OpenDCIM-DeleteAccess
OpenDCIM-RackRequest
OpenDCIM-RackAdmin
OpenDCIM-BulkOperations
OpenDCIM-AdminOwnDevices
Then populate the groups with either individual users or groups that users
are a member of. e.g. add the Network Ops group to OpenDCIM-SiteAccess,
OpenDCIM-ReadAccess and OpenDCIM-AdminOwnDevices groups.
Edit the OpenDCIM configuration via the web interface and change the LDAP
parameters.
LDAP Server URI: Needs to point to a Global Catalog server in the root
domain (e.g. dc1.domain.local:3268)
Base DN: Should be the base DN for the root domain (e.g. dc=domain,dc=local)
Bind DN: Should be set to %userid%
User Search: Should be set to (|(userPrincipalName=%userid%))
Note: Base Search is no longer used and can be ignored.
Set the DN for the groups, e.g.:
Site Access: CN=OpenDCIM-SiteAccess,OU=OpenDCIM,OU=Security
Groups,DC=domain,DC=local
(if the OpenDCIM-SiteAccess group lives in domain.local/Security
Groups/OpenDCIM)
Replace login_ldap.php with the attached.
Now users should be able to login with their UPN (user principle name),
e.g. ***@eu.domain.local or whatever their UPN is set to in AD.
This modified version of login_ldap.php:
1. Attempts to authenticate the user against AD. If the user
authenticated...
2. Gets the groups the user is a member of.
3. Checks if the groups the user is a member of is a member of the
appropriate OpenDCIM group OR if the user itself is a member of the
appropriate OpenDCIM group.
Tested against 4.3 and 4.3.1 only.
Hopefully this is useful and maybe some of this could find its way in to a
future release. I'd suggest possibly another authentication method called
"AD" so that it decouples AD from LDAP and would make maintaining and
testing code easier.
Regards,
David.