mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
14c6879f06
|
@ -17,7 +17,7 @@ class LdapSync extends Command
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'snipeit:ldap-sync {--location=} {--location_id=} {--base_dn=} {--summary} {--json_summary}';
|
||||
protected $signature = 'snipeit:ldap-sync {--location=} {--location_id=} {--base_dn=} {--filter=} {--summary} {--json_summary}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
|
@ -80,7 +80,11 @@ class LdapSync extends Command
|
|||
} else {
|
||||
$search_base = null;
|
||||
}
|
||||
if ($this->option('filter') != '') {
|
||||
$results = Ldap::findLdapUsers($search_base, -1, $this->option('filter'));
|
||||
} else {
|
||||
$results = Ldap::findLdapUsers($search_base);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if ($this->option('json_summary')) {
|
||||
$json_summary = ['error' => true, 'error_message' => $e->getMessage(), 'summary' => []];
|
||||
|
@ -109,7 +113,7 @@ class LdapSync extends Command
|
|||
}
|
||||
|
||||
/* Process locations with explicitly defined OUs, if doing a full import. */
|
||||
if ($this->option('base_dn') == '') {
|
||||
if ($this->option('base_dn') == '' && $this->option('filter') == '') {
|
||||
// Retrieve locations with a mapped OU, and sort them from the shallowest to deepest OU (see #3993)
|
||||
$ldap_ou_locations = Location::where('ldap_ou', '!=', '')->get()->toArray();
|
||||
$ldap_ou_lengths = [];
|
||||
|
|
|
@ -275,9 +275,10 @@ class Ldap extends Model
|
|||
* @since [v3.0]
|
||||
* @param $base_dn
|
||||
* @param $count
|
||||
* @param $filter
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function findLdapUsers($base_dn = null, $count = -1)
|
||||
public static function findLdapUsers($base_dn = null, $count = -1, $filter = null)
|
||||
{
|
||||
$ldapconn = self::connectToLdap();
|
||||
self::bindAdminToLdap($ldapconn);
|
||||
|
@ -285,7 +286,9 @@ class Ldap extends Model
|
|||
if (is_null($base_dn)) {
|
||||
$base_dn = Setting::getSettings()->ldap_basedn;
|
||||
}
|
||||
if($filter === null) {
|
||||
$filter = Setting::getSettings()->ldap_filter;
|
||||
}
|
||||
|
||||
// Set up LDAP pagination for very large databases
|
||||
$page_size = 500;
|
||||
|
|
Loading…
Reference in a new issue