通过用户名和从 PHP 到 Apache 的密码

发布于 2025-01-05 03:52:16 字数 439 浏览 4 评论 0原文

我有一个登录表单,用户可以使用两个不同的帐户登录 - 一个是 SolarisLDAP 帐户,另一个是 Active Directory 帐户。 当用户尝试登录时,我想找出他使用哪个帐户(这不是问题)。

如果他使用 SolarisLDAP 帐户,则身份验证是在 PHP 中完成的。 但如果它是 AD 帐户,则必须将其传递给 Apache(因为我必须使用 mod_auth_kerb 对我们的 AD 进行身份验证)。

我想知道这是否有可能以任何方式实现。我可以设置 $_SERVER['PHP_AUTH_USER']$_SERVER['PHP_AUTH_PW']$_SERVER['REMOTE_USER'],就是这样?

或者是否有可能通过标头或重定向来做到这一点?

希望你明白我想做什么..

干杯

I have a loginform where users can login with two different accounts - one is a SolarisLDAP account and the other is an Active Directory account.
When the user tries to log in I want to find out which account he uses (which is not the problem).

If he's using the SolarisLDAP account, the authentication is done in PHP.
But if it is an AD account it must be passed to Apache (because I have to use the mod_auth_kerb to authenticate against our AD).

I wonder if this is possible in any way. Could I just set $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'], or $_SERVER['REMOTE_USER'], and that's it?

Or would it be a possibility to kinda do it via the headers or a redirect?

Hope you understand what I'm trying to do..

Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忘你却要生生世世 2025-01-12 03:52:16

我想知道这是否有可能以任何方式实现。

不幸的是——没有。

另请注意,在这种情况下,将任何变量从 PHP 传递到 Apache 都是没有意义的。
您想要使用 Apache 进行身份验证的不是 PHP,而是浏览器,而且显然您无法控制。

I wonder if this is possible in any way.

Unfortunately - no.

Also note that passing whatever variables from PHP to Apache makes no sense in that context.
It is not PHP but browser you want to authenticate with Apache, and, obviously, you have no control of.

零崎曲识 2025-01-12 03:52:16

这取决于 apache 为请求设置的环境变量。执行 a

 var_dump($_SERVER);

获取所有可用的列表。浏览该列表并找出哪些与身份验证相关。这可能是非标准的,这是一个一般列表: http://php.net/_SERVER,比较一下与您的 var_dump 输出。

此外,这可能取决于您使用的服务器 API (SAPI) PHP文档

This depends on which environment variables apache does set for the request. Do a

 var_dump($_SERVER);

to get a list of all available ones. Go through that list and find out which ones are related to the authentication. It's probably something non-standard, this is a general list: http://php.net/_SERVER, compare it with your var_dump output.

Also this might depend on which Server-API (SAPI) you're using with PHPDocs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文