您可以按@符号展开并根据需要验证第二部分(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 块正在执行。我想我在配置中犯了错误请帮助我谢谢你登录控制器 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'); } }环境文件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条经验 获得超3个赞
最后,我在 laravel App 中完成了 LDAP 连接。如果有人在连接 LDAP 时遇到困难,请使用此软件包https://ldaprecord.com/docs/laravel/。关于在 laravel 中集成 LDAP 的非常清晰的解释。
- 1 回答
- 0 关注
- 215 浏览
添加回答
举报
0/150
提交
取消