Retrieve ldap entry from user model

This commit is contained in:
Râu Cao
2023-02-25 15:30:23 +08:00
parent 30fb9805e5
commit 678e80a25d
2 changed files with 7 additions and 1 deletions

View File

@@ -70,6 +70,12 @@ class User < ApplicationRecord
end
end
def ldap_entry
return @ldap_entry if defined?(@ldap_entry)
ldap = LdapService.new
@ldap_entry = ldap.fetch_users(uid: self.cn, ou: self.ou).first
end
def address
"#{self.cn}@#{self.ou}"
end