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
1a14e8f9
Commit
1a14e8f9
authored
Jan 18, 2017
by
Côme Chilliet
Browse files
Fixes
#946
Merged move and rename methods, moved the result to simplePlugin
parent
21eddfc2
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/class_plugin.inc
View file @
1a14e8f9
...
...
@@ -31,78 +31,6 @@ class plugin
var
$acl_base
=
""
;
var
$acl_category
=
""
;
/*!
* \brief Rename/Move a given src_dn to the given dest_dn
*
* Move a given ldap object indentified by $src_dn to the
* given destination $dst_dn
*
* \param string $src_dn the source DN.
*
* \param string $dst_dn the destination DN.
*
* \return boolean TRUE on success else FALSE.
*/
private
function
rename
(
$src_dn
,
$dst_dn
)
{
global
$config
;
/* Try to move the source entry to the destination position */
$ldap
=
$config
->
get_ldap_link
();
$ldap
->
cd
(
$config
->
current
[
'BASE'
]);
$ldap
->
create_missing_trees
(
preg_replace
(
'/^[^,]+,/'
,
''
,
$dst_dn
));
if
(
!
$ldap
->
rename_dn
(
$src_dn
,
$dst_dn
))
{
logging
::
log
(
'debug'
,
'Ldap Protocol v3 implementation error, ldap_rename failed.'
,
"FROM:
$src_dn
-- TO:
$dst_dn
"
,
array
(),
$ldap
->
get_error
());
@
DEBUG
(
DEBUG_LDAP
,
__LINE__
,
__FUNCTION__
,
__FILE__
,
"Rename failed FROM:
$src_dn
-- TO:
$dst_dn
"
,
'Ldap Protocol v3 implementation error. Error:'
.
$ldap
->
get_error
());
return
FALSE
;
}
return
TRUE
;
}
/*!
* \brief Move ldap entries from one place to another
*
* \param string $src_dn the source DN.
*
* \param string $dst_dn the destination DN.
*/
function
move
(
$src_dn
,
$dst_dn
)
{
global
$config
,
$ui
;
/* Do not move if only case has changed */
if
(
strtolower
(
$src_dn
)
==
strtolower
(
$dst_dn
))
{
return
TRUE
;
}
/* Try to move with ldap routines */
if
(
!
$this
->
rename
(
$src_dn
,
$dst_dn
))
{
return
FALSE
;
}
/* Update userinfo if necessary */
if
(
preg_match
(
'/'
.
preg_quote
(
$src_dn
,
'/'
)
.
'$/i'
,
$ui
->
dn
))
{
$ui_dn
=
preg_replace
(
'/'
.
preg_quote
(
$src_dn
,
'/'
)
.
'$/i'
,
$dst_dn
,
$ui
->
dn
);
logging
::
log
(
'view'
,
'acl/'
.
get_class
(
$this
),
$this
->
dn
,
array
(),
'Updated userinfo dn from "'
.
$ui
->
dn
.
'" to "'
.
$ui_dn
.
'"'
);
$ui
->
dn
=
$ui_dn
;
}
/* Check if departments were moved. If so, force the reload of config->departments */
$ldap
=
$config
->
get_ldap_link
();
$ldap
->
cd
(
$dst_dn
);
$ldap
->
search
(
'(objectClass=gosaDepartment)'
,
array
(
'dn'
));
if
(
$ldap
->
count
())
{
$config
->
get_departments
();
$config
->
make_idepartments
();
$ui
->
reset_acl_cache
();
}
$this
->
handleForeignKeys
(
$src_dn
,
$dst_dn
);
return
TRUE
;
}
/*!
* \brief Set acl base
*
...
...
include/simpleplugin/class_simplePlugin.inc
View file @
1a14e8f9
...
...
@@ -538,6 +538,54 @@ class simplePlugin extends plugin
return
$deps
;
}
/*!
* \brief Move ldap entries from one place to another
*
* \param string $src_dn the source DN.
*
* \param string $dst_dn the destination DN.
*/
function
move
(
$src_dn
,
$dst_dn
)
{
global
$config
,
$ui
;
/* Do not move if only case has changed */
if
(
strtolower
(
$src_dn
)
==
strtolower
(
$dst_dn
))
{
return
TRUE
;
}
/* Try to move with ldap routines */
$ldap
=
$config
->
get_ldap_link
();
$ldap
->
cd
(
$config
->
current
[
'BASE'
]);
$ldap
->
create_missing_trees
(
preg_replace
(
'/^[^,]+,/'
,
''
,
$dst_dn
));
if
(
!
$ldap
->
rename_dn
(
$src_dn
,
$dst_dn
))
{
logging
::
log
(
'debug'
,
'Ldap Protocol v3 implementation error, ldap_rename failed.'
,
"FROM:
$src_dn
-- TO:
$dst_dn
"
,
array
(),
$ldap
->
get_error
());
@
DEBUG
(
DEBUG_LDAP
,
__LINE__
,
__FUNCTION__
,
__FILE__
,
"Rename failed FROM:
$src_dn
-- TO:
$dst_dn
"
,
'Ldap Protocol v3 implementation error. Error:'
.
$ldap
->
get_error
());
return
FALSE
;
}
/* Update userinfo if necessary */
if
(
preg_match
(
'/'
.
preg_quote
(
$src_dn
,
'/'
)
.
'$/i'
,
$ui
->
dn
))
{
$ui_dn
=
preg_replace
(
'/'
.
preg_quote
(
$src_dn
,
'/'
)
.
'$/i'
,
$dst_dn
,
$ui
->
dn
);
logging
::
log
(
'view'
,
'acl/'
.
get_class
(
$this
),
$this
->
dn
,
array
(),
'Updated userinfo dn from "'
.
$ui
->
dn
.
'" to "'
.
$ui_dn
.
'"'
);
$ui
->
dn
=
$ui_dn
;
}
/* Check if departments were moved. If so, force the reload of config->departments */
$ldap
->
cd
(
$dst_dn
);
$ldap
->
search
(
'(objectClass=gosaDepartment)'
,
array
(
'dn'
));
if
(
$ldap
->
count
())
{
$config
->
get_departments
();
$config
->
make_idepartments
();
$ui
->
reset_acl_cache
();
}
$this
->
handleForeignKeys
(
$src_dn
,
$dst_dn
);
return
TRUE
;
}
function
getRequiredAttributes
()
{
$tmp
=
array
();
...
...
Côme Chilliet
@cchilliet
mentioned in issue
#350 (closed)
·
Sep 02, 2017
mentioned in issue
#350 (closed)
mentioned in issue #350
Toggle commit list
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