Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fusiondirectory
fusiondirectory
Commits
1bf9c9e6
Commit
1bf9c9e6
authored
Aug 19, 2014
by
Côme Bernigaud
Committed by
Benoit Mortier
Mar 03, 2015
Browse files
Fixes
#1955
fixed one and whole unicity modes
parent
a618e0d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/simpleplugin/class_attribute.inc
View file @
1bf9c9e6
...
...
@@ -122,7 +122,7 @@ class Attribute
function
setUnique
(
$unique
)
{
if
(
$unique
===
TRUE
)
{
$this
->
unique
=
'
sub
'
;
$this
->
unique
=
'
one
'
;
}
else
{
$this
->
unique
=
$unique
;
}
...
...
@@ -420,30 +420,65 @@ class Attribute
return
;
}
$ldap
=
$this
->
plugin
->
config
->
get_ldap_link
();
if
(
$this
->
unique
===
'whole'
)
{
$ldap
->
cd
(
$this
->
plugin
->
config
->
current
[
'BASE'
]);
}
else
{
$base
=
$this
->
plugin
->
config
->
current
[
'BASE'
];
if
(
$this
->
unique
!==
'whole'
)
{
if
(
isset
(
$this
->
plugin
->
base
)
&&
!
empty
(
$this
->
plugin
->
base
))
{
$base
=
$this
->
plugin
->
base
;
}
elseif
(
isset
(
$this
->
plugin
->
dn
)
&&
!
empty
(
$this
->
plugin
->
dn
)
&&
(
$this
->
plugin
->
dn
!=
'new'
))
{
$base
=
dn2base
(
$this
->
plugin
->
dn
);
}
else
{
$base
=
$this
->
plugin
->
config
->
current
[
'BASE'
];
}
$ldap
->
cd
(
$base
);
}
$ldap
->
cd
(
$base
);
$filter
=
"("
.
$this
->
getLdapName
()
.
"="
.
$value
.
")"
;
$pluginFilter
=
$this
->
plugin
->
getObjectClassFilter
();
if
(
!
empty
(
$pluginFilter
))
{
$filter
=
"(&
$pluginFilter$filter
)"
;
}
if
(
$this
->
unique
===
'one'
)
{
$ldap
->
ls
(
$filter
,
""
,
array
(
$this
->
getLdapName
()));
}
else
{
$ldap
->
search
(
$filter
,
array
(
$this
->
getLdapName
()));
}
$ldap
->
search
(
$filter
,
array
(
$this
->
getLdapName
()));
$infos
=
pluglist
::
pluginInfos
(
get_class
(
$this
->
plugin
));
$branches
=
array_map
(
function
(
$key
,
$ot
)
{
if
(
!
is_numeric
(
$key
))
{
$ot
=
$key
;
}
$oinfos
=
objects
::
infos
(
$ot
);
return
$oinfos
[
'ou'
];
},
array_keys
(
$infos
[
'plObjectType'
]),
array_values
(
$infos
[
'plObjectType'
])
);
while
(
$attrs
=
$ldap
->
fetch
())
{
if
(
$attrs
[
'dn'
]
!=
$this
->
plugin
->
dn
)
{
$dn_base
=
preg_replace
(
'/^[^,]+,/'
,
''
,
$attrs
[
'dn'
]);
$found
=
FALSE
;
if
(
$this
->
unique
===
'one'
)
{
/* Check that this entry is in a concerned branch */
$dn_branch
=
preg_replace
(
'/,'
.
preg_quote
(
$base
,
'/'
)
.
'$/'
,
''
,
$dn_base
);
foreach
(
$branches
as
$branch
)
{
if
(
$branch
.
$base
==
$dn_base
)
{
$dn_base
=
preg_replace
(
'/^'
.
preg_quote
(
$branch
,
'/'
)
.
'/'
,
''
,
$dn_base
);
$found
=
TRUE
;
break
;
}
}
}
else
{
/* whole (or sub) */
/* Check that this entry is in a concerned branch */
foreach
(
$branches
as
$branch
)
{
if
(
preg_match
(
'/^'
.
preg_quote
(
$branch
,
'/'
)
.
'/'
,
$dn_base
))
{
$dn_base
=
preg_replace
(
'/^'
.
preg_quote
(
$branch
,
'/'
)
.
'/'
,
''
,
$dn_base
);
$found
=
TRUE
;
break
;
}
}
if
(
!
in_array
(
$dn_base
,
$this
->
plugin
->
config
->
departments
))
{
continue
;
}
}
if
(
!
$found
)
{
continue
;
}
return
msgPool
::
duplicated
(
$this
->
getLabel
());
}
}
...
...
Write
Preview
Supports
Markdown
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