diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_auth_pam.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ejabberd_auth_pam.erl b/src/ejabberd_auth_pam.erl index aff0a226..b99c7cbd 100644 --- a/src/ejabberd_auth_pam.erl +++ b/src/ejabberd_auth_pam.erl @@ -60,7 +60,11 @@ check_password(User, Server, Password, _Digest, _DigestGen) -> check_password(User, Host, Password) -> Service = get_pam_service(Host), - case catch epam:authenticate(Service, User, Password) of + UserInfo = case get_pam_userinfotype(Host) of + username -> User; + jid -> User++"@"++Host + end, + case catch epam:authenticate(Service, UserInfo, Password) of true -> true; _ -> false end. @@ -84,7 +88,11 @@ get_password_s(_User, _Server) -> %% TODO: Improve this function to return an error instead of 'false' when connection to PAM failed is_user_exists(User, Host) -> Service = get_pam_service(Host), - case catch epam:acct_mgmt(Service, User) of + UserInfo = case get_pam_userinfotype(Host) of + username -> User; + jid -> User++"@"++Host + end, + case catch epam:acct_mgmt(Service, UserInfo) of true -> true; _ -> false end. @@ -106,3 +114,8 @@ get_pam_service(Host) -> undefined -> "ejabberd"; Service -> Service end. +get_pam_userinfotype(Host) -> + case ejabberd_config:get_local_option({pam_userinfotype, Host}) of + undefined -> username; + Type -> Type + end. |