C++ 中的 Windows LDAP 身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3206526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:47:35  来源:igfitidea点击:

Windows LDAP Authentication in C++

c++windowsauthenticationldap

提问by thecaptain0220

I am currently trying to authenticate users in a c++ application in Windows. I need to display a dialog for username and password and verify that they are an authenticated user on the Windows machine. Are there any libraries that allow for this functionality or a good way to go about it?

我目前正在尝试在 Windows 中的 c++ 应用程序中对用户进行身份验证。我需要显示用户名和密码的对话框,并验证它们是 Windows 机器上经过身份验证的用户。是否有任何库允许此功能或实现它的好方法?

回答by Oleg

Probably CredUIPromptForWindowsCredentials(see http://msdn.microsoft.com/en-us/library/aa375178.aspx) or old CredUIPromptForCredentials(see http://msdn.microsoft.com/en-us/library/aa375177.aspx) could solve your problem?

可能CredUIPromptForWindowsCredentials(参见http://msdn.microsoft.com/en-us/library/aa375178.aspx)或旧的CredUIPromptForCredentials(参见http://msdn.microsoft.com/en-us/library/aa375177.aspx)可以解决您的问题问题?

UPDATED: Another the most old way to authenticate a user is using of SSPI. It will not help with displaying a dialog but this can you implement yourself. You can find a very old code example (probably the first one published by Microsoft) here http://support.microsoft.com/kb/180548.

更新:另一种最古老的用户身份验证方法是使用 SSPI。显示对话框无济于事,但您可以自己实现。您可以在http://support.microsoft.com/kb/180548 上找到一个非常古老的代码示例(可能是 Microsoft 发布的第一个示例)。

If you do want use LDAP API (see http://msdn.microsoft.com/en-us/library/aa366102.aspx) you can use ldap_bind_s(see http://msdn.microsoft.com/en-us/library/aa366156.aspx) to verify user authentication. See http://msdn.microsoft.com/en-us/library/aa366106.aspxas a code example (it is not exactly what you want, but you can understand how these API work)

如果您确实想使用 LDAP API(请参阅http://msdn.microsoft.com/en-us/library/aa366102.aspx),您可以使用ldap_bind_s(请参阅http://msdn.microsoft.com/en-us/library/ aa366156.aspx) 来验证用户身份验证。参见http://msdn.microsoft.com/en-us/library/aa366106.aspx作为代码示例(这不完全是你想要的,但你可以理解这些 API 是如何工作的)