Error while logging with AD user

Problem:
Hello everyone,

when I log using AD user for the first time, the user will be created and then occur a backtrace error. Here is the log.

2022-09-19T11:41:33 [I|app|3beb8920] Started POST "/users/login" for 10.108.243.80 at 2022-09-19 11:41:33 +0200
2022-09-19T11:41:33 [I|app|3beb8920] Processing by UsersController#login as HTML
2022-09-19T11:41:33 [I|app|3beb8920]   Parameters: {"login"=>{"login"=>"elnsi", "password"=>"[FILTERED]"}, "authenticity_token"=>"PsYKpQqkmmQC3FDtYaho7pI9ePaiJ9jP8r12CJzC1TJ0LvHpohxd5CLL4AbzILFuhkU8sHBpPL0zfECxrhTFYg=="}
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on login ELNSI
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on firstname Afeef
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on lastname Ghannam
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on mail
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on admin false
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on auth_source_id 7
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on locale
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on avatar_hash
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on default_organization_id
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on default_location_id
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on lower_login elnsi
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on mail_enabled true
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on timezone
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on description
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on disabled false
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on password [redacted]
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on role_ids []
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on usergroup_ids []
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on organization_ids [1]
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) create event on location_ids [2]
2022-09-19T11:41:33 [I|app|3beb8920] ForemanWebhooks::EventSubscriber: user_created.event.foreman event received
2022-09-19T11:41:33 [I|aud|3beb8920] User (18) update event on usergroup_ids , 5
2022-09-19T11:41:33 [I|app|3beb8920] ForemanWebhooks::EventSubscriber: user_updated.event.foreman event received
2022-09-19T11:41:33 [W|app|3beb8920] undefined method '#name' for User::Jail (User)
2022-09-19T11:41:33 [I|app|3beb8920] Backtrace for 'undefined method '#name' for User::Jail (User)' error (Safemode::NoMethodError): undefined method '#name' for User::Jail (User)
 3beb8920 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.6/lib/safemode/jail.rb:22:in `method_missing'
 3beb8920 | HTTP header template:53:in `bind'
 3beb8920 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.6/lib/safemode.rb:51:in `eval'
 3beb8920 | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.6/lib/safemode.rb:51:in `eval'
 3beb8920 | /usr/share/foreman/lib/foreman/renderer/safe_mode_renderer.rb:7:in `render'
 3beb8920 | /usr/share/foreman/lib/foreman/renderer/base_renderer.rb:18:in `render'
 3beb8920 | /usr/share/foreman/lib/foreman/renderer.rb:46:in `render'
 3beb8920 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_webhooks-2.0.1/app/models/w

With ldapsearch I can find the user:

ldapsearch -x -H ldaps://****** -D "AD-Username*****" -W -b "*********" "(sAMAccountName=elnsi)"

# extended LDIF
#
# LDAPv3
# base <DC=*****,DC=****,DC=*****> with scope subtree
# filter: (sAMAccountName=elnsi)
# requesting: ALL
#

# ELNSI, CWID, ****
dn: CN=ELNSI,OU=****,DC=***,DC=***,DC=***
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: user
cn: ELNSI
sn: Gh*****
l: Bergkamen
givenName: Af****
distinguishedName: CN=***********
instanceType: 4
whenCreated: 20200519101736.0Z
whenChanged: 20220919071324.0Z
displayName: Af*** Gh*****
uSNCreated: 50705038
info: 12
memberOf: *********

When I disable the safemode, I get another error with the usage of another module ip

Foreman versions:
foreman-2.5.2.21-1.el7sat.noarch