Closed ellisonpatterson closed 2 years ago
Hi @ellisonpatterson!
Can you post your model code? If you extend the ActiveDirectory\Entry
model, the objectsid
conversion should happen automatically:
The objectguid
attribute should also be converted automatically in all models:
Otherwise, you will have to convert these manually (they are binary values and will break serialization).
@stevebauman
My model class is extending LdapRecord\Models\ActiveDirectory\User
.
Here is my model class:
<?php
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Routing\UrlRoutable;
use LdapRecord\Models\Concerns\CanAuthenticate;
use LdapRecord\Models\Attributes\AccountControl;
use LdapRecord\Models\ActiveDirectory\User as ActiveDirectory;
use Carbon\Carbon;
class User extends ActiveDirectory implements Authenticatable, UrlRoutable
{
use CanAuthenticate, Notifiable;
public function getId()
{
return $this->getConvertedGuid();
}
public function getFullName()
{
return $this->getFirstAttribute('name');
}
public function getEmail()
{
return $this->getFirstAttribute('userPrincipalName');
}
public function isDisabled()
{
return $this->userAccountControl()->has(AccountControl::ACCOUNTDISABLE);
}
public function mustChangePassword()
{
return !$this->pwdLastSet;
}
public function canChangePassword()
{
return !$this->userAccountControl()->has(AccountControl::PASSWD_CANT_CHANGE);
}
public function canPasswordExpire()
{
return !$this->userAccountControl()->has(AccountControl::DONT_EXPIRE_PASSWORD);
}
public function whenPasswordExpires()
{
$lastChange = Carbon::parse($this->pwdLastSet);
return Carbon::parse($lastChange)->addDays(config('sso.password_max_age'));
}
public function hasPasswordExpired()
{
return Carbon::parse($this->whenPasswordExpires())->isPast();
}
public function userAccountControl(array $value = [])
{
$ac = new AccountControl($value[0] ?? null);
$ac->setValues($ac->extractFlags($this->getFirstAttribute('userAccountControl')));
return $ac;
}
public function getRouteKey()
{
return $this->getId();
}
public function getRouteKeyName()
{
return 'user';
}
public function resolveRouteBinding($value, $field = null)
{
return (new self)->findByGuid($value);
}
public function resolveChildRouteBinding($childType, $value, $field)
{
return null;
}
public function routeNotificationForMail($notification = null)
{
return $this->getEmail();
}
}
Thanks @ellisonpatterson! I'm able to reproduce this error locally with my Active Directory instance. Patching now 👍
Moved this to the LdapRecord repository since this is a core issue 👍
Fixed in v2.12.0 🎉
Thank you so much!
Environment:
Describe the bug: If I make a model (extending Laravel Model or the LdapDirectory Model) and add the notifiable trait, I am unable to notify that user if I have the notification queue-able. You get this error:
I found that it is some encoding issue and have to put this before I use notify:
Some type of UTF8 issue or something, but running those three lines allows the user model to be queues successfully without issue.
Could this be handled in the library potentially?
Thank you!