如何使用 iOS 应用程序向 Active Directory 进行身份验证

发布于 2024-12-08 16:18:13 字数 124 浏览 0 评论 0原文

我正在尝试创建一个 iOS 应用程序,该应用程序获取用户凭据并使用 AD 服务器验证它。 xCode 中是否有一些内置库可以做到这一点,或者它是第三方的?

任何关于寻找方向的建议将不胜感激。

谢谢 扎克

I am trying to create and iOS app that takes a users credentials and verifies it with the AD server. Is there some built in library in xCode to do that, or is it third party?

Any advice on direction to look would be greatly appreciated.

Thanks
Zach

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

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

发布评论

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

评论(2

雪化雨蝶 2024-12-15 16:18:13

好的,这就是我用来连接 ldap 服务器的 PHP。我不是 100% 确定这里发生了什么,我从我公司的 IT 协调员那里得到了这个代码。我了解所有绑定和搜索部分,但我不明白整个事情的 ldap_set_option 部分。不管怎样,这样设置之后,你就可以调用php脚本的URL并传递参数了。看一下 PHP 和下面的 url 示例。

<?php
//Connection parameters
$dn = "DC=network,DC=net";
$host = "ldap://ldap.network.com";
$port = 1111

$user = $_GET['user'];
$pass = $_GET['pass'];

//$user = "[email protected]";
//$pass = "pass";

$filter = "memberof";
$keyword = "CN=USSC_ALL,CN=Users,DC=network,DC=net";

$filter = "objectclass";
$keyword = "user";

$filter = "objectcategory";
$keyword = "CN=Person,CN=Schema,CN=Configuration,DC=network,DC=net";

//The real thing with PHP
if (!empty($keyword) and !empty($dn)) {
//Connect to the AD
$adConn = ldap_connect($host, $port) or die("Could not connect!");

//Set protocol verison
ldap_set_option($adConn, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap     protocol1");

//Set referrals... Won't work without this...
ldap_set_option($adConn, LDAP_OPT_REFERRALS, 0) or die ("Could not set ldap protocol2");

//Bind the user
$bd = ldap_bind($adConn, $user, $pass) or die ("Could not bind");

echo $bd;

 //End binding
ldap_unbind($adConn);



} else {
   echo "<p>No results found!</p>";
}

?>


</body>
</html>  

好的,现在您所要做的就是将用户名和密码传递给脚本,它将返回绑定。这会给你 true 或 false。这意味着如果绑定成功,则表明用户名和密码的组合正确。

这就是我的称呼:

http://192.268.192.1/ldap.php?user=(username here)&pass=(password here)

这是我采取的方法,我认为这是一个非常简单的答案。

Ok, so this was the PHP i used to make the connection to the ldap server. i am not 100% sure what is happening here, i got this code from IT Coordinator at my company. I understand all the binding and searching parts, but i dont get the the ldap_set_option part of this whole thing. Anyway after setting it up this way, you can then call the URL of the php script and pass it parameters. take a look at the PHP, and the url example with be below.

<?php
//Connection parameters
$dn = "DC=network,DC=net";
$host = "ldap://ldap.network.com";
$port = 1111

$user = $_GET['user'];
$pass = $_GET['pass'];

//$user = "[email protected]";
//$pass = "pass";

$filter = "memberof";
$keyword = "CN=USSC_ALL,CN=Users,DC=network,DC=net";

$filter = "objectclass";
$keyword = "user";

$filter = "objectcategory";
$keyword = "CN=Person,CN=Schema,CN=Configuration,DC=network,DC=net";

//The real thing with PHP
if (!empty($keyword) and !empty($dn)) {
//Connect to the AD
$adConn = ldap_connect($host, $port) or die("Could not connect!");

//Set protocol verison
ldap_set_option($adConn, LDAP_OPT_PROTOCOL_VERSION, 3) or die ("Could not set ldap     protocol1");

//Set referrals... Won't work without this...
ldap_set_option($adConn, LDAP_OPT_REFERRALS, 0) or die ("Could not set ldap protocol2");

//Bind the user
$bd = ldap_bind($adConn, $user, $pass) or die ("Could not bind");

echo $bd;

 //End binding
ldap_unbind($adConn);



} else {
   echo "<p>No results found!</p>";
}

?>


</body>
</html>  

Ok so now all you have to do is pass a username and password to the script and it will return the bind. that will give you either true or false. meaning if it bound successfully it is a correct combination of username and password.

this is how i am calling it:

http://192.268.192.1/ldap.php?user=(username here)&pass=(password here)

This is the approach that i took, and i think it is a very simple answer.

私野 2024-12-15 16:18:13

所以我发现我需要使用 PHP 来做到这一点。通过在服务器上创建一个 php 文件,我可以使用内置的 ldap 协议将用户名和密码发送到 ldap 服务器进行验证。然后查询应返回 true 或 false。一旦我得到这个工作,我就会发布我的代码

So what I have been able to find out is that i need to use PHP to do this. By creating a php file on the server, i can use built in ldap protocol to take a user name and password to the ldap server for verification. The query should then return true or false. As soon as i get this working ill post my code

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