Hey Côme, hey Andreas.

> string|FALSE ldap_exop_whoami(resource $link) - The returned string is
> the DN of the currently bound user.

In my opinion the code is really ease to read with exceptions.

try {
    $user = ldap_exop_whoami($link);
}
catch(Throwable $e) {
}

string|FALSE ldap_exop_passwd(resource $link [, string $user [, string
$oldPassword [, string $newPassword]]] - The returned string is the new
password of the user. Either the given newPassword or a newly generated one.

Change password of current user with a random password.
ldap_exop_passwd($link);

Change password of $user with a random password.
ldap_exop_passwd($link, $user);

Change $oldPassword of $user with a random password.
ldap_exop_passwd($link, $user, $oldPassword);

Change $oldPassword of $user to $newPassword.
ldap_exop_passwd($link, $user, $oldPassword, $newPassword);

As i wrote the four samples, i actually already like the ordering of the arguments as it seems to make sense.


How is the behavior of the following?

Change $oldPassword of current user to $newPassword?
ldap_exop_passwd($link, '', $oldPassword, $newPassword);

Change $oldPassword of $user to empty string? Or random? Or is this an error?
ldap_exop_passwd($link, $user, $oldPassword, '');


My previous suggestion was to split the function into two versions to reduce the amount of arguments.

string|FALSE ldap_exop_passwd(resource $link, string $user, string
$newPassword [, string $oldPassword])

string|FALSE ldap_exop_random_passwd(resource $link, string $user [, string $oldPassword])


Or is that complete and utter nonsense?

Maybe, so lets talk about the functions. i dont like the unnecessary references. But if the references makes more sense in this situation, please use them.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to