Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
19918879
Commit
19918879
authored
Jul 28, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Auth) add extended query to user search
parent
28a9a3e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
LDAP.php
src/opnsense/mvc/app/library/OPNsense/Auth/LDAP.php
+9
-2
No files found.
src/opnsense/mvc/app/library/OPNsense/Auth/LDAP.php
View file @
19918879
...
@@ -87,6 +87,7 @@ class LDAP
...
@@ -87,6 +87,7 @@ class LDAP
{
{
$result
=
false
;
$result
=
false
;
if
(
$this
->
ldapHandle
!=
null
)
{
if
(
$this
->
ldapHandle
!=
null
)
{
// if we're looking at multple dn's, split and combine output
foreach
(
explode
(
";"
,
$this
->
baseSearchDN
)
as
$baseDN
)
{
foreach
(
explode
(
";"
,
$this
->
baseSearchDN
)
as
$baseDN
)
{
if
(
$ldap_scope
==
"one"
)
{
if
(
$ldap_scope
==
"one"
)
{
$sr
=@
ldap_list
(
$this
->
ldapHandle
,
$baseDN
,
$filter
,
$this
->
ldapSearchAttr
);
$sr
=@
ldap_list
(
$this
->
ldapHandle
,
$baseDN
,
$filter
,
$this
->
ldapSearchAttr
);
...
@@ -161,15 +162,21 @@ class LDAP
...
@@ -161,15 +162,21 @@ class LDAP
* search user by name or expression
* search user by name or expression
* @param $username string username(s) to search
* @param $username string username(s) to search
* @param $userNameAttribute string ldap attribute to use for the search
* @param $userNameAttribute string ldap attribute to use for the search
* @param $extendedQuery string|null additional search criteria (narrow down search)
* @return array|bool
* @return array|bool
*/
*/
public
function
searchUsers
(
$username
,
$userNameAttribute
)
public
function
searchUsers
(
$username
,
$userNameAttribute
,
$extendedQuery
=
null
)
{
{
if
(
$this
->
ldapHandle
!==
false
)
{
if
(
$this
->
ldapHandle
!==
false
)
{
// add $userNameAttribute to search results
// add $userNameAttribute to search results
$this
->
addSearchAttribute
(
$userNameAttribute
);
$this
->
addSearchAttribute
(
$userNameAttribute
);
$result
=
array
();
$result
=
array
();
$searchResults
=
$this
->
search
(
"(
{
$userNameAttribute
}
=
{
$username
}
)"
);
if
(
empty
(
$extendedQuery
))
{
$searchResults
=
$this
->
search
(
"(
{
$userNameAttribute
}
=
{
$username
}
)"
);
}
else
{
// add additional search phrases
$searchResults
=
$this
->
search
(
"(&(
{
$userNameAttribute
}
=
{
$username
}
)(
{
$extendedQuery
}
))"
);
}
if
(
$searchResults
!==
false
)
{
if
(
$searchResults
!==
false
)
{
for
(
$i
=
0
;
$i
<
$searchResults
[
"count"
];
$i
++
)
{
for
(
$i
=
0
;
$i
<
$searchResults
[
"count"
];
$i
++
)
{
// fetch distinguished name and most likely username (try the search field first)
// fetch distinguished name and most likely username (try the search field first)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment