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
6f2ce708
Commit
6f2ce708
authored
Dec 11, 2013
by
Côme Bernigaud
Committed by
Benoit Mortier
Dec 11, 2013
Browse files
Fixes:
#2595
Removed some duplicated blocks
parent
227cd384
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/class_ldap.inc
View file @
6f2ce708
...
...
@@ -792,6 +792,11 @@ class LDAP{
}
}
/*
* $target is a dn, i.e. "ou=example,ou=orga,dc=base"
*
* Creates missing trees, in our example ou=orga,dc=base will get created if not existing, same thing for ou=example,ou=orga,dc=base
* */
function
create_missing_trees
(
$srp
,
$target
)
{
$real_path
=
substr
(
$target
,
0
,
strlen
(
$target
)
-
strlen
(
$this
->
basedn
)
-
1
);
...
...
@@ -838,7 +843,6 @@ class LDAP{
/* Automatic or traditional? */
if
(
count
(
$classes
))
{
/* Get name of first matching objectClass */
$ocname
=
""
;
foreach
(
$classes
as
$class
)
{
...
...
@@ -881,9 +885,7 @@ class LDAP{
$na
[
$attr
]
=
"filled"
;
}
}
}
else
{
/* Use alternative add... */
switch
(
$type
)
{
case
'ou'
:
...
...
@@ -904,7 +906,6 @@ class LDAP{
$this
->
add
(
$na
);
if
(
!
$this
->
success
())
{
print_a
(
array
(
$cdn
,
$na
));
msg_dialog
::
display
(
_
(
"LDAP error"
),
msgPool
::
ldaperror
(
$this
->
get_error
(),
$cdn
,
LDAP_ADD
,
get_class
()));
...
...
setup/class_setupStep_Migrate.inc
View file @
6f2ce708
...
...
@@ -858,7 +858,6 @@ class Step_Migrate extends setup_step
}
}
}
elseif
(
$tmp
[
1
]
==
"role"
)
{
/* Check if acl owner is a valid FusionDirectory user account */
$ldap
->
cat
(
base64_decode
(
$tmp
[
2
]),
array
(
"gosaAclTemplate"
));
$ret
=
$ldap
->
fetch
();
...
...
@@ -1920,13 +1919,11 @@ class Step_Migrate extends setup_step
}
function
get_user_list
()
function
get_user_list
(
$class
=
'gosaAccount'
)
{
/* Establish ldap connection */
$cv
=
$this
->
parent
->
captured_values
;
$ldap
=
$this
->
get_ldap_link
();
$ldap
->
cd
(
$cv
[
'base'
]);
$ldap
->
search
(
"(objectClass=gosaAccount)"
,
array
(
"dn"
));
$ldap
->
search
(
"(objectClass=
$class
)"
,
array
(
"dn"
));
$tmp
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
...
...
@@ -1936,108 +1933,53 @@ class Step_Migrate extends setup_step
}
function
get_
all_people_ous
()
function
get_
group_list
()
{
/* Get collected configuration settings */
$cv
=
$this
->
parent
->
captured_values
;
$people_ou
=
trim
(
$cv
[
'peopleou'
]);
/* Establish ldap connection */
$cv
=
$this
->
parent
->
captured_values
;
$ldap
=
$this
->
get_ldap_link
();
/*****************
* If people ou is NOT empty
* search for for all objects matching the given container
*****************/
if
(
!
empty
(
$people_ou
))
{
$ldap
->
search
(
"("
.
$people_ou
.
")"
,
array
(
"dn"
));
/* Create people ou if there is currently none */
if
(
$ldap
->
count
()
==
0
)
{
$add_dn
=
$cv
[
'peopleou'
]
.
","
.
$cv
[
'base'
];
$naming_attr
=
preg_replace
(
"/=.*$/"
,
""
,
$add_dn
);
$naming_value
=
preg_replace
(
"/^[^=]*+=([^,]*).*$/"
,
"
\\
1"
,
$add_dn
);
$add
=
array
();
$add
[
'objectClass'
]
=
array
(
"organizationalUnit"
);
$add
[
$naming_attr
]
=
$naming_value
;
$ldap
->
cd
(
$cv
[
'base'
]);
$ldap
->
create_missing_trees
(
preg_replace
(
"/^[^,]+,/"
,
""
,
$add_dn
));
$ldap
->
cd
(
$add_dn
);
$ldap
->
add
(
$add
);
}
return
$this
->
get_user_list
(
'posixGroup'
);
}
/* Create result */
$ldap
->
search
(
"("
.
$cv
[
'peopleou'
]
.
")"
,
array
(
"dn"
));
$tmp
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
if
(
!
preg_match
(
"/ou=snapshots,/"
,
$attrs
[
'dn'
]))
{
$tmp
[
base64_encode
(
$attrs
[
'dn'
])]
=
$ldap
->
fix
(
$attrs
[
'dn'
]);
}
}
}
else
{
/************
* If people ou is empty
* Get all valid gosaDepartments
************/
$ldap
->
cd
(
$cv
[
'base'
]);
$tmp
=
array
();
$ldap
->
search
(
"(&(objectClass=gosaDepartment)(ou=*))"
,
array
(
"dn"
));
$tmp
[
base64_encode
(
$cv
[
'base'
])]
=
$ldap
->
fix
(
$cv
[
'base'
]);
while
(
$attrs
=
$ldap
->
fetch
())
{
$tmp
[
base64_encode
(
$attrs
[
'dn'
])]
=
$ldap
->
fix
(
$attrs
[
'dn'
]);;
}
}
return
$tmp
;
function
get_all_people_ous
()
{
return
$this
->
get_all_ous
(
'peopleou'
);
}
function
get_all_group_ous
()
{
return
$this
->
get_all_ous
(
'groupou'
);
}
function
get_all_ous
(
$cv_key
)
{
/* Establish ldap connection */
$cv
=
$this
->
parent
->
captured_values
;
$ldap
=
$this
->
get_ldap_link
();
$group_ou
=
trim
(
$cv
[
'groupou'
]);
if
(
!
empty
(
$group_ou
))
{
$group_ou
=
trim
(
$group_ou
);
}
$ou
=
trim
(
$cv
[
$cv_key
]);
/************
* If
group
ou is NOT empty
* Get all valid
group
ous, create one if necessary
* If ou is NOT empty
* Get all valid ous, create one if necessary
************/
$ldap
->
cd
(
$cv
[
'base'
]);
if
(
!
empty
(
$group_ou
))
{
$ldap
->
search
(
"("
.
$group_ou
.
")"
,
array
(
"dn"
));
if
(
!
empty
(
$ou
))
{
$ldap
->
search
(
"(
$ou
)"
,
array
(
'dn'
));
if
(
$ldap
->
count
()
==
0
)
{
$add_dn
=
$group_ou
.
$cv
[
'base'
];
$naming_attr
=
preg_replace
(
"/=.*$/"
,
""
,
$add_dn
);
$naming_value
=
preg_replace
(
"/^[^=]*+=([^,]*).*$/"
,
"
\\
1"
,
$add_dn
);
$add
=
array
();
$add
[
'objectClass'
]
=
array
(
"organizationalUnit"
);
$add
[
$naming_attr
]
=
$naming_value
;
$ldap
->
cd
(
$cv
[
'base'
]);
$ldap
->
create_missing_trees
(
preg_replace
(
"/^[^,]+,/"
,
""
,
$add_dn
));
$ldap
->
cd
(
$add_dn
);
$ldap
->
add
(
$add
);
$ldap
->
create_missing_trees
(
$ou
.
$cv
[
'base'
]);
}
$ldap
->
search
(
"(
"
.
$group_ou
.
"
)"
,
array
(
"
dn
"
));
$ldap
->
search
(
"(
$ou
)"
,
array
(
'
dn
'
));
$tmp
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
if
(
!
preg_match
(
"
/ou=snapshots,/
"
,
$attrs
[
'dn'
]))
{
if
(
!
preg_match
(
'
/ou=snapshots,/
'
,
$attrs
[
'dn'
]))
{
$tmp
[
base64_encode
(
$attrs
[
'dn'
])]
=
$ldap
->
fix
(
$attrs
[
'dn'
]);
}
}
}
else
{
/************
* If
group
ou is empty
* If ou is empty
* Get all valid gosaDepartments
************/
$ldap
->
cd
(
$cv
[
'base'
]);
$tmp
=
array
();
$ldap
->
search
(
"
(&(objectClass=gosaDepartment)(ou=*))
"
,
array
(
"
dn
"
));
$ldap
->
search
(
'
(&(objectClass=gosaDepartment)(ou=*))
'
,
array
(
'
dn
'
));
$tmp
[
base64_encode
(
$cv
[
'base'
])]
=
$ldap
->
fix
(
$cv
[
'base'
]);
while
(
$attrs
=
$ldap
->
fetch
())
{
$tmp
[
base64_encode
(
$attrs
[
'dn'
])]
=
$ldap
->
fix
(
$attrs
[
'dn'
]);;
...
...
@@ -2047,23 +1989,6 @@ class Step_Migrate extends setup_step
}
function
get_group_list
()
{
/* Establish ldap connection */
$cv
=
$this
->
parent
->
captured_values
;
$ldap
=
$this
->
get_ldap_link
();
$ldap
->
cd
(
$cv
[
'base'
]);
$ldap
->
search
(
"(objectClass=posixGroup)"
,
array
(
"dn"
));
$tmp
=
array
();
while
(
$attrs
=
$ldap
->
fetch
())
{
$tmp
[
base64_encode
(
$attrs
[
'dn'
])]
=
LDAP
::
fix
(
$attrs
[
'dn'
]);
}
return
$tmp
;
}
function
move
(
$source
,
$destination
)
{
/* Establish ldap connection */
...
...
@@ -2072,7 +1997,6 @@ class Step_Migrate extends setup_step
/* Update object references in gosaGroupOfNames */
$ogs_to_fix
=
array
();
$ldap
->
cd
(
$cv
[
'base'
]);
$ldap
->
search
(
'(&(objectClass=gosaGroupOfNames)(member='
.
@
LDAP
::
prepare4filter
(
$source
)
.
'))'
,
array
(
'cn'
,
'member'
));
while
(
$attrs
=
$ldap
->
fetch
())
{
$dn
=
$attrs
[
'dn'
];
...
...
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