Skip to content

Commit 70854d5

Browse files
committed
Compute macros before building DN (ltb-project#225)
1 parent b3e418c commit 70854d5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

htdocs/create.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@
5050

5151
$create_attributes['objectclass'] = $create_objectclass;
5252

53-
$dn = "";
54-
55-
foreach ($create_dn_items as $dn_item) {
56-
$attribute = $attributes_map[$dn_item]['attribute'];
57-
if ($dn) { $dn .= "+"; }
58-
$dn .= $attribute . "=" . ldap_escape($create_attributes[$attribute][0], "", LDAP_ESCAPE_DN);
59-
}
60-
61-
$dn .= "," . $create_base;
62-
6353
# Use macros
6454
foreach ($create_items_macros as $item => $macro) {
6555
$value = preg_replace_callback('/%(\w+)%/',
@@ -71,6 +61,17 @@ function ($matches) use ($item, $create_attributes, $attributes_map) {
7161
$create_attributes[ $attributes_map[$item]['attribute'] ] = $value;
7262
}
7363

64+
# Build DN
65+
$dn = "";
66+
67+
foreach ($create_dn_items as $dn_item) {
68+
$attribute = $attributes_map[$dn_item]['attribute'];
69+
if ($dn) { $dn .= "+"; }
70+
$dn .= $attribute . "=" . ldap_escape($create_attributes[$attribute][0], "", LDAP_ESCAPE_DN);
71+
}
72+
73+
$dn .= "," . $create_base;
74+
7475
# Create entry
7576
if (!ldap_add($ldap, $dn, $create_attributes)) {
7677
error_log("LDAP - modify failed for $dn");

0 commit comments

Comments
 (0)