Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
ff5497e9
Commit
ff5497e9
authored
9 years ago
by
David Yang
Browse files
Options
Downloads
Patches
Plain Diff
- Added search.filter to allow for custom LDAP search filters
parent
3e6647e1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config-templates/authsources.php
+3
-0
3 additions, 0 deletions
config-templates/authsources.php
lib/SimpleSAML/Auth/LDAP.php
+9
-3
9 additions, 3 deletions
lib/SimpleSAML/Auth/LDAP.php
modules/ldap/lib/ConfigHelper.php
+6
-1
6 additions, 1 deletion
modules/ldap/lib/ConfigHelper.php
with
18 additions
and
4 deletions
config-templates/authsources.php
+
3
−
0
View file @
ff5497e9
...
...
@@ -303,6 +303,9 @@ $config = array(
// array of strings, in which case they will be searched in the order given.
'search.base' => 'ou=people,dc=example,dc=org',
// Additional LDAP filters appended to the default search
'search.filter' => '(objectclass=inetorgperson)',
// The attribute(s) the username should match against.
//
// This is an array with one or more attribute names. Any of the attributes in
...
...
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Auth/LDAP.php
+
9
−
3
View file @
ff5497e9
...
...
@@ -202,7 +202,7 @@ class SimpleSAML_Auth_LDAP {
* @throws SimpleSAML_Error_UserNotFound if:
* - Zero entries was found
*/
private
function
search
(
$base
,
$attribute
,
$value
)
{
private
function
search
(
$base
,
$attribute
,
$value
,
$searchFilter
=
NULL
)
{
// Create the search filter
$attribute
=
self
::
escape_filter_value
(
$attribute
,
FALSE
);
...
...
@@ -213,6 +213,11 @@ class SimpleSAML_Auth_LDAP {
}
$filter
=
'(|'
.
$filter
.
')'
;
// Append LDAP filters if defined
if
(
$searchFilter
!=
NULL
)
{
$filter
=
"(&"
.
$filter
.
""
.
$searchFilter
.
")"
;
}
// Search using generated filter
SimpleSAML_Logger
::
debug
(
'Library - LDAP search(): Searching base \''
.
$base
.
'\' for \''
.
$filter
.
'\''
);
// TODO: Should aliases be dereferenced?
...
...
@@ -271,7 +276,7 @@ class SimpleSAML_Auth_LDAP {
* - $allowZeroHits er TRUE and no result is found
*
*/
public
function
searchfordn
(
$base
,
$attribute
,
$value
,
$allowZeroHits
=
FALSE
)
{
public
function
searchfordn
(
$base
,
$attribute
,
$value
,
$allowZeroHits
=
FALSE
,
$searchFilter
=
NULL
)
{
// Traverse all search bases, returning DN if found
$bases
=
SimpleSAML\Utils\Arrays
::
arrayize
(
$base
);
...
...
@@ -279,7 +284,8 @@ class SimpleSAML_Auth_LDAP {
foreach
(
$bases
AS
$current
)
{
try
{
// Single base search
$result
=
$this
->
search
(
$current
,
$attribute
,
$value
);
$result
=
$this
->
search
(
$current
,
$attribute
,
$value
,
$searchFilter
);
// We don't hawe to look any futher if user is found
if
(
!
empty
(
$result
))
{
return
$result
;
...
...
This diff is collapsed.
Click to expand it.
modules/ldap/lib/ConfigHelper.php
+
6
−
1
View file @
ff5497e9
...
...
@@ -81,6 +81,10 @@ class sspmod_ldap_ConfigHelper {
*/
private
$searchBase
;
/**
* Additional LDAP filter fields for the search
*/
private
$searchFilter
;
/**
* The attributes which should match the username.
...
...
@@ -149,6 +153,7 @@ class sspmod_ldap_ConfigHelper {
}
$this
->
searchBase
=
$config
->
getArrayizeString
(
'search.base'
);
$this
->
searchFilter
=
$config
->
getString
(
'search.filter'
,
NULL
);
$this
->
searchAttributes
=
$config
->
getArray
(
'search.attributes'
);
}
else
{
...
...
@@ -197,7 +202,7 @@ class sspmod_ldap_ConfigHelper {
}
}
$dn
=
$ldap
->
searchfordn
(
$this
->
searchBase
,
$this
->
searchAttributes
,
$username
,
TRUE
);
$dn
=
$ldap
->
searchfordn
(
$this
->
searchBase
,
$this
->
searchAttributes
,
$username
,
TRUE
,
$this
->
searchFilter
);
if
(
$dn
===
NULL
)
{
/* User not found with search. */
SimpleSAML_Logger
::
info
(
$this
->
location
.
': Unable to find users DN. username=\''
.
$username
.
'\''
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment