Take the 2-minute tour ×

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

share|improve this question
add comment

2 Answers

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

share|improve this answer
add comment
up vote 0 down vote accepted

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.

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

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

//$user = "user@network.net";
//$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

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



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: here)&pass=(password here)

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

share|improve this answer
You should NOT be using a url param to post user credentials. You should also be using SSL. I recommend setting up an SSL cert on your box and using a form to post these credentials. –  rwyland Mar 30 '12 at 14:27
add comment

Your Answer


