Merge branch 'develop' of https://github.com/snipe/snipe-it into develop
This commit is contained in:
commit
c1a4fbee16
3 changed files with 64 additions and 46 deletions
|
@ -26,6 +26,7 @@ class LDAPImportController extends Controller
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->ldap = $ldap;
|
$this->ldap = $ldap;
|
||||||
|
$this->ldap->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Adldap\Schemas\Schema;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Helpers\Helper;
|
use App\Helpers\Helper;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
@ -94,7 +95,6 @@ class LdapAd extends LdapAdConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should we sync the logged in user
|
// Should we sync the logged in user
|
||||||
try {
|
|
||||||
Log::debug('Attempting to find user in LDAP directory');
|
Log::debug('Attempting to find user in LDAP directory');
|
||||||
$record = $this->ldap->search()->findBy($this->ldapSettings['ldap_username_field'], $username);
|
$record = $this->ldap->search()->findBy($this->ldapSettings['ldap_username_field'], $username);
|
||||||
|
|
||||||
|
@ -104,11 +104,6 @@ class LdapAd extends LdapAdConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log::error($e->getMessage());
|
|
||||||
throw new Exception('Unable to find user in LDAP directory!');
|
|
||||||
}
|
|
||||||
} catch (ModelNotFoundException $e) {
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
throw new Exception('Unable to find user in LDAP directory!');
|
throw new Exception('Unable to find user in LDAP directory!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +137,8 @@ class LdapAd extends LdapAdConfiguration
|
||||||
$snipeUser['lastname'] = $user->{$this->ldapSettings['ldap_lname_field']}[0] ?? '';
|
$snipeUser['lastname'] = $user->{$this->ldapSettings['ldap_lname_field']}[0] ?? '';
|
||||||
$snipeUser['firstname'] = $user->{$this->ldapSettings['ldap_fname_field']}[0] ?? '';
|
$snipeUser['firstname'] = $user->{$this->ldapSettings['ldap_fname_field']}[0] ?? '';
|
||||||
$snipeUser['email'] = $user->{$this->ldapSettings['ldap_email']}[0] ?? '';
|
$snipeUser['email'] = $user->{$this->ldapSettings['ldap_email']}[0] ?? '';
|
||||||
|
$snipeUser['title'] = $user->getTitle() ?? '';
|
||||||
|
$snipeUser['telephonenumber'] = $user->getTelephoneNumber() ?? '';
|
||||||
$snipeUser['location_id'] = $this->getLocationId($user, $defaultLocation, $mappedLocations);
|
$snipeUser['location_id'] = $this->getLocationId($user, $defaultLocation, $mappedLocations);
|
||||||
$snipeUser['activated'] = $this->getActiveStatus($user);
|
$snipeUser['activated'] = $this->getActiveStatus($user);
|
||||||
|
|
||||||
|
@ -171,6 +168,8 @@ class LdapAd extends LdapAdConfiguration
|
||||||
$user->last_name = trim($userInfo['lastname']);
|
$user->last_name = trim($userInfo['lastname']);
|
||||||
$user->email = trim($userInfo['email']);
|
$user->email = trim($userInfo['email']);
|
||||||
$user->employee_num = trim($userInfo['employee_number']);
|
$user->employee_num = trim($userInfo['employee_number']);
|
||||||
|
$user->jobtitle = trim($userInfo['title']);
|
||||||
|
$user->phone = trim($userInfo['telephonenumber']);
|
||||||
$user->activated = $userInfo['activated'];
|
$user->activated = $userInfo['activated'];
|
||||||
$user->location_id = $userInfo['location_id'];
|
$user->location_id = $userInfo['location_id'];
|
||||||
$user->notes = 'Imported from LDAP';
|
$user->notes = 'Imported from LDAP';
|
||||||
|
@ -223,7 +222,7 @@ class LdapAd extends LdapAdConfiguration
|
||||||
*/
|
*/
|
||||||
private function isLdapSync(AdldapUser $user): bool
|
private function isLdapSync(AdldapUser $user): bool
|
||||||
{
|
{
|
||||||
return (false === $this->ldapSettings['ldap_active_flag'])
|
return (false == $this->ldapSettings['ldap_active_flag'])
|
||||||
|| ('true' == strtolower($user->{$this->ldapSettings['ldap_active_flag']}[0]));
|
|| ('true' == strtolower($user->{$this->ldapSettings['ldap_active_flag']}[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,11 +244,11 @@ class LdapAd extends LdapAdConfiguration
|
||||||
* Check to see if we are connected to an AD server
|
* Check to see if we are connected to an AD server
|
||||||
* if so, check the Active Directory User Account Control Flags
|
* if so, check the Active Directory User Account Control Flags
|
||||||
*/
|
*/
|
||||||
if ($this->ldapSettings['is_ad']) {
|
if ($user->hasAttribute($user->getSchema()->userAccountControl())) {
|
||||||
$activeStatus = (in_array($user->getUserAccountControl(), self::AD_USER_ACCOUNT_CONTROL_FLAGS)) ? 1 : 0;
|
$activeStatus = (in_array($user->getUserAccountControl(), self::AD_USER_ACCOUNT_CONTROL_FLAGS)) ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
// If there is no activated flag, assume this is handled via the OU and activate the users
|
// If there is no activated flag, assume this is handled via the OU and activate the users
|
||||||
if (false === $this->ldapSettings['ldap_active_flag']) {
|
if (false == $this->ldapSettings['ldap_active_flag']) {
|
||||||
$activeStatus = 1;
|
$activeStatus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +280,7 @@ class LdapAd extends LdapAdConfiguration
|
||||||
// Check to see if the user is in a mapped location
|
// Check to see if the user is in a mapped location
|
||||||
if ($mappedLocations) {
|
if ($mappedLocations) {
|
||||||
$location = $mappedLocations->filter(function ($value, $key) use ($user) {
|
$location = $mappedLocations->filter(function ($value, $key) use ($user) {
|
||||||
if ($user->inGroup([$value], true)) {
|
if ($user->inOu($value)) {
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -348,6 +347,8 @@ class LdapAd extends LdapAdConfiguration
|
||||||
*/
|
*/
|
||||||
private function getSelectedFields(): array
|
private function getSelectedFields(): array
|
||||||
{
|
{
|
||||||
|
/** @var Schema $schema */
|
||||||
|
$schema = new $this->ldapConfig['schema'];
|
||||||
return [
|
return [
|
||||||
$this->ldapSettings['ldap_username_field'],
|
$this->ldapSettings['ldap_username_field'],
|
||||||
$this->ldapSettings['ldap_fname_field'],
|
$this->ldapSettings['ldap_fname_field'],
|
||||||
|
@ -355,8 +356,10 @@ class LdapAd extends LdapAdConfiguration
|
||||||
$this->ldapSettings['ldap_email'],
|
$this->ldapSettings['ldap_email'],
|
||||||
$this->ldapSettings['ldap_emp_num'],
|
$this->ldapSettings['ldap_emp_num'],
|
||||||
$this->ldapSettings['ldap_active_flag'],
|
$this->ldapSettings['ldap_active_flag'],
|
||||||
'memberOf',
|
$schema->memberOf(),
|
||||||
'useraccountcontrol',
|
$schema->userAccountControl(),
|
||||||
|
$schema->title(),
|
||||||
|
$schema->telephone(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,21 @@
|
||||||
[v-cloak] {
|
[v-cloak] {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Rules for the div table */
|
||||||
|
.tbl_head {
|
||||||
|
font-weight: bold
|
||||||
|
}
|
||||||
|
.div_tbl {
|
||||||
|
display: table
|
||||||
|
}
|
||||||
|
.div_tbl_row {
|
||||||
|
display: table-row
|
||||||
|
}
|
||||||
|
.div_tbl_cell {
|
||||||
|
display: table-cell;
|
||||||
|
padding: 2px
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
@ -49,24 +64,24 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12" style="padding-top: 30px;">
|
<div class="col-md-12" style="padding-top: 30px;">
|
||||||
<table class="table table-striped" id="upload-table">
|
<div class="table table-striped div_tbl" id="upload-table">
|
||||||
<thead>
|
<div class="div_tbl_row">
|
||||||
<th>File</th>
|
<div class="div_tbl_cell tbl_head">File</div>
|
||||||
<th>Created</th>
|
<div class="div_tbl_cell tbl_head">Created</div>
|
||||||
<th>Size</th>
|
<div class="div_tbl_cell tbl_head">Size</div>
|
||||||
<th></th>
|
<div class="div_tbl_cell tbl_head"></div>
|
||||||
</thead>
|
</div>
|
||||||
<tbody>
|
|
||||||
<template v-for="currentFile in files">
|
<template v-for="currentFile in files">
|
||||||
<tr>
|
<div class="div_tbl_row">
|
||||||
<td>@{{ currentFile.file_path }}</td>
|
<div class="div_tbl_cell">@{{ currentFile.file_path }}</div>
|
||||||
<td>@{{ currentFile.created_at }} </td>
|
<div class="div_tbl_cell">@{{ currentFile.created_at }} </div>
|
||||||
<td>@{{ currentFile.filesize }}</td>
|
<div class="div_tbl_cell">@{{ currentFile.filesize }}</div>
|
||||||
<td>
|
<div class="div_tbl_cell">
|
||||||
<button class="btn btn-sm btn-info" @click="toggleEvent(currentFile.id)">Process</button>
|
<button class="btn btn-sm btn-info" @click="toggleEvent(currentFile.id)">Process</button>
|
||||||
<button class="btn btn-sm btn-danger" @click="deleteFile(currentFile)"><i class="fa fa-trash icon-white"></i></button>
|
<button class="btn btn-sm btn-danger" @click="deleteFile(currentFile)"><i class="fa fa-trash icon-white"></i></button>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
</div>
|
||||||
<import-file
|
<import-file
|
||||||
:key="currentFile.id"
|
:key="currentFile.id"
|
||||||
:file="currentFile"
|
:file="currentFile"
|
||||||
|
@ -74,8 +89,7 @@
|
||||||
@alert="updateAlert(alert)">
|
@alert="updateAlert(alert)">
|
||||||
</import-file>
|
</import-file>
|
||||||
</template>
|
</template>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue