Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
6c670cb8
Commit
6c670cb8
authored
12 years ago
by
Arthur Schiwon
Browse files
Options
Downloads
Patches
Plain Diff
LDAP: more cleanup
parent
333e8986
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/user_ldap/group_ldap.php
+2
-26
2 additions, 26 deletions
apps/user_ldap/group_ldap.php
with
2 additions
and
26 deletions
apps/user_ldap/group_ldap.php
+
2
−
26
View file @
6c670cb8
...
@@ -40,12 +40,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
...
@@ -40,12 +40,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
public
function
inGroup
(
$uid
,
$gid
)
{
public
function
inGroup
(
$uid
,
$gid
)
{
$dn_user
=
OC_LDAP
::
username2dn
(
$uid
);
$dn_user
=
OC_LDAP
::
username2dn
(
$uid
);
$dn_group
=
OC_LDAP
::
groupname2dn
(
$gid
);
$dn_group
=
OC_LDAP
::
groupname2dn
(
$gid
);
// if($dn_group == 'c') {echo('#sdfsdgfds');die($gid);}
// just in case
// just in case
if
(
!
$dn_group
||
!
$dn_user
)
{
if
(
!
$dn_group
||
!
$dn_user
)
{
return
false
;
return
false
;
}
}
// var_dump($dn_group);
$members
=
OC_LDAP
::
readAttribute
(
$dn_group
,
LDAP_GROUP_MEMBER_ASSOC_ATTR
);
$members
=
OC_LDAP
::
readAttribute
(
$dn_group
,
LDAP_GROUP_MEMBER_ASSOC_ATTR
);
return
in_array
(
$dn_user
,
$members
);
return
in_array
(
$dn_user
,
$members
);
...
@@ -69,7 +67,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
...
@@ -69,7 +67,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
$this
->
ldapGroupFilter
,
$this
->
ldapGroupFilter
,
LDAP_GROUP_MEMBER_ASSOC_ATTR
.
'='
.
$userDN
LDAP_GROUP_MEMBER_ASSOC_ATTR
.
'='
.
$userDN
));
));
$groups
=
$this
->
retrieveList
(
$filter
,
array
(
OC_LDAP
::
conf
(
'ldapGroupDisplayName'
),
'dn'
));
$groups
=
OC_LDAP
::
fetchListOfGroups
(
$filter
,
array
(
OC_LDAP
::
conf
(
'ldapGroupDisplayName'
),
'dn'
));
$userGroups
=
OC_LDAP
::
ownCloudGroupNames
(
$groups
);
$userGroups
=
OC_LDAP
::
ownCloudGroupNames
(
$groups
);
return
array_unique
(
$userGroups
,
SORT_LOCALE_STRING
);
return
array_unique
(
$userGroups
,
SORT_LOCALE_STRING
);
...
@@ -99,7 +97,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
...
@@ -99,7 +97,7 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
* Returns a list with all groups
* Returns a list with all groups
*/
*/
public
function
getGroups
()
{
public
function
getGroups
()
{
$ldap_groups
=
$this
->
retrieveList
(
$this
->
ldapGroupFilter
,
array
(
OC_LDAP
::
conf
(
'ldapGroupDisplayName'
),
'dn'
));
$ldap_groups
=
OC_LDAP
::
fetchListOfGroups
(
$this
->
ldapGroupFilter
,
array
(
OC_LDAP
::
conf
(
'ldapGroupDisplayName'
),
'dn'
));
$groups
=
OC_LDAP
::
ownCloudGroupNames
(
$ldap_groups
);
$groups
=
OC_LDAP
::
ownCloudGroupNames
(
$ldap_groups
);
return
$groups
;
return
$groups
;
}
}
...
@@ -112,26 +110,4 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
...
@@ -112,26 +110,4 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
public
function
groupExists
(
$gid
){
public
function
groupExists
(
$gid
){
return
in_array
(
$gid
,
$this
->
getGroups
());
return
in_array
(
$gid
,
$this
->
getGroups
());
}
}
private
function
retrieveList
(
$filter
,
$attr
,
$searchForGroups
=
true
)
{
if
(
$searchForGroups
)
{
$list
=
OC_LDAP
::
searchGroups
(
$filter
,
$attr
);
}
else
{
$list
=
OC_LDAP
::
searchUsers
(
$filter
,
$attr
);
}
if
(
is_array
(
$list
))
{
if
(
count
(
$attr
)
>
1
){
return
$list
;
}
else
{
return
array_unique
(
$list
,
SORT_LOCALE_STRING
);
}
}
//error cause actually, maybe throw an exception in future.
return
array
();
}
}
}
\ No newline at end of file
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