mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
More AD fixes
This commit is contained in:
parent
0cf8ac1d95
commit
99a42dfc38
|
@ -62,27 +62,29 @@ class Ldap extends Model
|
|||
* array of ldap_attributes if $user is true
|
||||
*
|
||||
*/
|
||||
static function findAndBindUserLdap($username, $password) {
|
||||
|
||||
static function findAndBindUserLdap($username, $password)
|
||||
{
|
||||
$settings = Setting::getSettings();
|
||||
$connection = Ldap::connectToLdap();
|
||||
$ldap_username_field = $settings->ldap_username_field;
|
||||
$baseDn = $settings->ldap_basedn;
|
||||
|
||||
$ldap_username_field = Setting::getSettings()->ldap_username_field;
|
||||
$baseDn = Setting::getSettings()->ldap_basedn;
|
||||
|
||||
if (Setting::getSettings()->is_ad=='1') {
|
||||
if ($settings->is_ad =='1')
|
||||
{
|
||||
|
||||
// In case they haven't added an AD domain
|
||||
if (Setting::getSettings()->ad_domain='') {
|
||||
$userDn = $username.'@'.Setting::getSettings()->email_domain;
|
||||
if ($settings->ad_domain ='') {
|
||||
$userDn = $username.'@'.$settings->email_domain;
|
||||
} else {
|
||||
$userDn = $username.'@'.Setting::getSettings()->ad_domain;
|
||||
$userDn = $username.'@'.$settings->ad_domain;
|
||||
}
|
||||
|
||||
} else {
|
||||
$userDn = $ldap_username_field.'='.$username.','.Setting::getSettings()->ldap_basedn;
|
||||
$userDn = $ldap_username_field.'='.$username.','.$settings->ldap_basedn;
|
||||
}
|
||||
|
||||
$filterQuery = Setting::getSettings()->ldap_auth_filter_query . $username;
|
||||
|
||||
$filterQuery = $settings->ldap_auth_filter_query . $username;
|
||||
|
||||
if (!$ldapbind = @ldap_bind($connection, $userDn, $password)) {
|
||||
return false;
|
||||
|
@ -116,7 +118,8 @@ class Ldap extends Model
|
|||
* false if the username and/or password provided are invalid
|
||||
*
|
||||
*/
|
||||
static function bindAdminToLdap($connection) {
|
||||
static function bindAdminToLdap($connection)
|
||||
{
|
||||
|
||||
$ldap_username = Setting::getSettings()->ldap_uname;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class AddAdDomainToSettings extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('settings', function (Blueprint $table) {
|
||||
$table->text('ad_domain')->nullable()->default(NULL);
|
||||
$table->string('ad_domain')->nullable()->default(NULL);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -694,13 +694,13 @@
|
|||
<!-- AD Domain -->
|
||||
<div class="form-group {{ $errors->has('ad_domain') ? 'error' : '' }}">
|
||||
<div class="col-md-3">
|
||||
{{ Form::label('ldap_server', trans('admin/settings/general.ad_domain')) }}
|
||||
{{ Form::label('ad_domain', trans('admin/settings/general.ad_domain')) }}
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@if (config('app.lock_passwords')===true)
|
||||
{{ Form::text('ad_domain', Input::old('ad_domain', $setting->ad_domain), array('class' => 'form-control', 'disabled'=>'disabled','placeholder' => 'example.com')) }}
|
||||
@else
|
||||
{{ Form::text('ad_domain', Input::old('ldap_server', $setting->ad_domain), array('class' => 'form-control','placeholder' => 'example.com')) }}
|
||||
{{ Form::text('ad_domain', Input::old('ad_domain', $setting->ad_domain), array('class' => 'form-control','placeholder' => 'example.com')) }}
|
||||
@endif
|
||||
|
||||
<p class="help-block">{{ trans('admin/settings/general.ad_domain_help') }}</p>
|
||||
|
|
Loading…
Reference in a new issue