mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-19 00:29:21 +01:00
LScli: fix --sub-dn autocompletion even if LDAP server not selected
This commit is contained in:
parent
3dc0d7f637
commit
6eee099bd2
1 changed files with 20 additions and 18 deletions
|
@ -409,6 +409,8 @@ class LScli extends LSlog_staticLoggerClass {
|
||||||
$command = null;
|
$command = null;
|
||||||
$command_arg_num = null;
|
$command_arg_num = null;
|
||||||
$command_args = array();
|
$command_args = array();
|
||||||
|
$ldap_server_id = false;
|
||||||
|
$ldap_server_subDn = false;
|
||||||
for ($i=1; $i < count($comp_words); $i++) {
|
for ($i=1; $i < count($comp_words); $i++) {
|
||||||
$unescaped_comp_word = $comp_words[$i];
|
$unescaped_comp_word = $comp_words[$i];
|
||||||
self :: unquote_word($unescaped_comp_word);
|
self :: unquote_word($unescaped_comp_word);
|
||||||
|
@ -438,17 +440,6 @@ class LScli extends LSlog_staticLoggerClass {
|
||||||
self :: unquote_word($ldap_server_id);
|
self :: unquote_word($ldap_server_id);
|
||||||
if(!LSsession :: setLdapServer($ldap_server_id))
|
if(!LSsession :: setLdapServer($ldap_server_id))
|
||||||
self :: usage("Fail to select LDAP server #$ldap_server_id.");
|
self :: usage("Fail to select LDAP server #$ldap_server_id.");
|
||||||
|
|
||||||
// Check if LDAP server has subDn and select the first one if true
|
|
||||||
self :: need_ldap_con();
|
|
||||||
$subDns = LSsession :: getSubDnLdapServer();
|
|
||||||
if (is_array($subDns)) {
|
|
||||||
asort($subDns);
|
|
||||||
$subDn = key($subDns);
|
|
||||||
if(!LSsession :: setSubDn($subDn))
|
|
||||||
self :: usage("Fail to select sub DN '$subDn'.");
|
|
||||||
$opts[] = '--sub-dn';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '--sub-dn':
|
case '--sub-dn':
|
||||||
|
@ -464,13 +455,11 @@ class LScli extends LSlog_staticLoggerClass {
|
||||||
}
|
}
|
||||||
if (!isset($comp_words[$i]))
|
if (!isset($comp_words[$i]))
|
||||||
break;
|
break;
|
||||||
if (isset($comp_words[$i])) {
|
$ldap_server_subDn = $comp_words[$i];
|
||||||
$subDn = $comp_words[$i];
|
self :: unquote_word($ldap_server_subDn);
|
||||||
self :: unquote_word($subDn);
|
|
||||||
self :: need_ldap_con();
|
self :: need_ldap_con();
|
||||||
if(!LSsession :: setSubDn($subDn))
|
if(!LSsession :: setSubDn($ldap_server_subDn))
|
||||||
self :: usage("Fail to select sub DN '$subDn'.");
|
self :: usage("Fail to select sub DN '$ldap_server_subDn'.");
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case '-L':
|
case '-L':
|
||||||
case '--load-class':
|
case '--load-class':
|
||||||
|
@ -510,6 +499,19 @@ class LScli extends LSlog_staticLoggerClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is no subDn selected, check if LDAP server has subDn and select the first one if true
|
||||||
|
if (!$ldap_server_subDn) {
|
||||||
|
self :: need_ldap_con();
|
||||||
|
$subDns = LSsession :: getSubDnLdapServer();
|
||||||
|
if (is_array($subDns)) {
|
||||||
|
asort($subDns);
|
||||||
|
$subDn = key($subDns);
|
||||||
|
if(!LSsession :: setSubDn($subDn))
|
||||||
|
self :: usage("Fail to select sub DN '$subDn'.");
|
||||||
|
$opts[] = '--sub-dn';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If command set and args autocompleter defined, use it
|
// If command set and args autocompleter defined, use it
|
||||||
if ($command && is_callable(self :: $commands[$command]['args_autocompleter'])) {
|
if ($command && is_callable(self :: $commands[$command]['args_autocompleter'])) {
|
||||||
$command_comp_word_num = $comp_word_num-$command_arg_num-1;
|
$command_comp_word_num = $comp_word_num-$command_arg_num-1;
|
||||||
|
|
Loading…
Reference in a new issue