|
21 | 21 |
|
22 | 22 | if ((!is_null($REDIS->getCache("initialized", "")) and (!array_key_exists("u", $options)))) {
|
23 | 23 | echo "cache is already initialized, nothing doing.";
|
24 |
| - echo " use -f argument to flush cache, or -u argument to update without flush."; |
| 24 | + echo " use -f argument to flush cache, or -u argument to update without flush.\n"; |
25 | 25 | } else {
|
26 | 26 | echo "updating cache...\n";
|
27 |
| - $user_ou = new LDAPEntry($LDAP->getConn(), $CONFIG["ldap"]["user_ou"]); |
28 | 27 | echo "waiting for LDAP response (users)...\n";
|
29 |
| - $users = $user_ou->getChildrenArray(true); |
| 28 | + $users = $LDAP->search("objectClass=posixAccount", $CONFIG["ldap"]["basedn"]); |
30 | 29 | echo "response received.\n";
|
31 | 30 | // phpcs:disable
|
32 |
| - $user_CNs = array_map(function ($x){return $x["cn"][0];}, $users); |
| 31 | + $user_CNs = array_map(function ($x){return $x->getAttribute("cn")[0];}, $users); |
33 | 32 | // phpcs:enable
|
34 | 33 | sort($user_CNs);
|
35 | 34 | $REDIS->setCache("sorted_users", "", $user_CNs);
|
36 | 35 | foreach ($users as $user) {
|
37 |
| - $attribute_array = UnityLDAP::parseUserChildrenArray($user); |
38 |
| - foreach ($attribute_array as $key => $val) { |
39 |
| - $REDIS->setCache($user["cn"][0], $key, $val); |
| 36 | + $cn = $user->getAttribute("cn")[0]; |
| 37 | + foreach ($user->getAttributes() as $key => $val) { |
| 38 | + $REDIS->setCache($cn, $key, $val); |
40 | 39 | }
|
41 | 40 | }
|
42 | 41 |
|
43 | 42 | $org_group_ou = new LDAPEntry($LDAP->getConn(), $CONFIG["ldap"]["orggroup_ou"]);
|
44 | 43 | echo "waiting for LDAP response (org_groups)...\n";
|
45 |
| - $org_groups = $org_group_ou->getChildrenArray(true); |
| 44 | + $org_groups = $LDAP->search("objectClass=posixGroup", $CONFIG["ldap"]["basedn"]); |
46 | 45 | echo "response received.\n";
|
47 | 46 | // phpcs:disable
|
48 |
| - $org_group_CNs = array_map(function($x){return $x["cn"][0];}, $org_groups); |
| 47 | + $org_group_CNs = array_map(function($x){return $x->getAttribute("cn")[0];}, $org_groups); |
49 | 48 | // phpcs:enable
|
50 | 49 | sort($org_group_CNs);
|
51 | 50 | $REDIS->setCache("sorted_orgs", "", $org_group_CNs);
|
52 | 51 | foreach ($org_groups as $org_group) {
|
53 |
| - $REDIS->setCache($org_group["cn"][0], "members", $org_group["memberuid"]); |
| 52 | + $REDIS->setCache($org_group->getAttribute("cn")[0], "members", $org_group->getAttribute("memberuid")); |
54 | 53 | }
|
55 | 54 |
|
56 | 55 | $pi_group_ou = new LDAPEntry($LDAP->getConn(), $CONFIG["ldap"]["pigroup_ou"]);
|
|
0 commit comments