您可以按@符號展開并根據(jù)需要驗證第二部分(1 個索引)。<?php$dataEmail = 'test@';$explodedEmail = explode('@', $dataEmail);if (array_key_exists(1, $explodedEmail) && strlen($explodedEmail[1]) > 0) { echo 'true';}但是,如果您需要驗證電子郵件,只需使用filter_var我正在使用 Adldap2-Laravel 包進行身份驗證。我正在使用 LDAP 測試論壇進行測試。我按照本教程 https://jotaelesalinas.github.io/laravel-simple-ldap-auth/ 但我無法登錄。我沒有收到任何錯誤。在下面的代碼中,總是 else 塊正在執(zhí)行。我想我在配置中犯了錯誤請幫助我謝謝你登錄控制器 protected function attemptLogin(Request $request) { $credentials = $request->only($this->username(), 'password'); $username = $credentials[$this->username()]; $password = $credentials['password']; $user_format = env('LDAP_USER_FORMAT', 'cn=%s,'.env('LDAP_BASE_DN', '')); $userdn = sprintf($user_format, $username); if(Adldap::auth()->attempt($userdn, $password, $bindAsUser = true)) { dd('working'); } else { dd('not working'); } }環(huán)境文件LDAP_SCHEMA=OpenLDAPLDAP_HOSTS=ldap.forumsys.comLDAP_BASE_DN=dc=example,dc=comLDAP_USER_ATTRIBUTE=uidLDAP_USER_FORMAT=uid=%s,dc=example,dc=comLDAP_CONNECTION=default# Change from mysql to sqlite:DB_CONNECTION=sqlite
1 回答

慕容3067478
TA貢獻1773條經(jīng)驗 獲得超3個贊
最后,我在 laravel App 中完成了 LDAP 連接。如果有人在連接 LDAP 時遇到困難,請使用此軟件包https://ldaprecord.com/docs/laravel/。關(guān)于在 laravel 中集成 LDAP 的非常清晰的解釋。
- 1 回答
- 0 關(guān)注
- 233 瀏覽
添加回答
舉報
0/150
提交
取消