Jump to content

Wireless Guest Registration through Active Directory using PHP with LDAP


Recommended Posts

Posted (edited)

Currently I am trying to get a handle on how to correctly set up a script to allow users to request guest wireless credentials using PHP with LDAP & Active Directory. Basically the guest will enter in their First Name, Last Name, and the Date(s) Service Needed - then it will create a temporary username and password for the guest with the credentials listed into the Active Directory.

Is my code even leaning in the right direction? What can be changed and what must be changed? How do I create the user itself? How do I create the random password? Can I do this all in one php file or do I need a separate html & php file?

If I could get a helping hand to help me get this started to at least get the right base for the script itself.

 

[color=#222222][font=Verdana]

$message = array();
$message_css = "";

function ldap_addGuest($object_name, $givenName, $SN, $pwdtxt){
global $message;
global $message_css;

$ldap_server = "localhost:390";
$AD_Auth_User = "[email protected]";
$AD_Auth_Pass = "password123";
  
$dn = "CN=".$object_name."OU=PathToaddGuest,DC=danieldefense,DC=com";
  
$newPassword = "\"" . $pwdtxt . "\"";
$len = strlen($newPassword);
$newPassw = "";

for($i=0;$i<$len;$i++) {
	$newPassw .= "{$newPassword{$i}}\000";
}

error_reporting(0);
$ds = ldap_connect($ldap_server);
	
if ($ds) {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$r = ldap_bind($ds, $AD_Auth_User, $AD_Auth_Pass); 

$adduserAD['CN'] = $object_name;
   $adduserAD['givenName'] = $givenName;
   $adduserAD['SN'] = $SN;
$adduserAD['date_request'] = $date;
   $adduserAD['objectclass'][0] = "top";
   $adduserAD['objectclass'][1] = "person";
   $adduserAD['objectclass'][1] = "organizationalPerson";
   $adduserAD['objectclass'][2] = "user";
   $adduserAD["unicodepwd"] = $newPassw;
   $adduserAD["sAMAccountName"] = $object_name;
   $adduserAD["UserAccountControl"] = "512"; 

   $r = ldap_add($ds, $dn, $adduserAD);

if(ldap_error($ds) == "Success")
	return true;
else
	return false;
}	
} 
?>




	Guest Wireless Signin
	<br />
			body { font-family: Verdana,Arial,Courier New; font-size: 0.7em; }<br />
			th { text-align: right; padding: 0.8em; }<br />
			#container { text-align: center; width: 500px; margin: 5% auto; }<br />
			.msg_yes { margin: 0 auto; text-align: center; color: green; background: #D4EAD4; border: 1px solid green; border-radius: 10px; margin: 2px; }<br />
			.msg_no { margin: 0 auto; text-align: center; color: red; background: #FFF0F0; border: 1px solid red; border-radius: 10px; margin: 2px; }<br />
		
	

	
		
			Guest Wireless Request Form					
if (isset($_POST["submitted"])) {
	ldap_addGuest($_POST['givenName'],$_POST['SN'],$_POST['date_request'],$_POST['unicodepwd']);
		global $message_css;
			if ($message_css == "yes") {
?>



	} else {
?>



	$message[] = "Guest user account not created.";
       }
       foreach ( $message as $one ) { echo "
$one"; }
?>



	} 
?>


	
		First Name:
		Last Name:
		Date(s) Service Needed:
		Password:
		
		
		
		Cancel
		
	



[/font][/color]

Edited by tpolwort
Posted

Going back a stage here, is this designed for self service? Or an admin user to do it?

 

If it's self service how are they going to access this page to request a login without having wifi access?

 

If they're creating their own accounts what stops them using it for anything bad and then just creating another account?

 

Steve

Posted
Going back a stage here, is this designed for self service? Or an admin user to do it?

 

If it's self service how are they going to access this page to request a login without having wifi access?

 

If they're creating their own accounts what stops them using it for anything bad and then just creating another account?

 

Steve

 

Self Service. Isn't it possible for that to be the only page accessible and the rest of the web locked?

 

And that's a good question about creating another account. Any ideas?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...