Salam...

saya mau tanya masalah LDAP Server di Linux neh sama para master2 linux 
sekalian.. :)

saya ingin buat form login, yang nantinya terkoneksi ke LDAP server..
yg ingin saya tanyakan, gimana cara dan script php-nya untuk menghubungkan 
script php form login agar terkoneksi ke LDAP server yg telah dibuat..??

Mohon bantuan para master2 sekalian..sebelumnya saya ucapkan terima kasih yg 
sebesar2nya..

ini script form login yg udah saya buat:

 <?php
//Disable error messages
error_reporting(0);
?>

<?php
if ($_POST) {

function cleanTxt($text)
{
$code_entities_match =

array('–','>','&quot;','!','#','$','%','^','&','*','(',')','{','}','|',':','"','<','[',']','\\',';',"'",',','/','*','~','`')
 ; 
$code_entities_replace = array('-','-',",",",",",",",",",",",",",",",",",");
$text = str_replace($code_entities_match, $code_entities_replace, $text);
return $text;
}
//Set form variables
$Username=stripslashes(cleanTxt($_POST['ssoname']));
$SSO_Password=stripslashes($_POST['ssopass']);

//Get Ip Address and User Agent information. This is useful info to store in 
sessions, or a database table, especially if you need to track timestamps and 
access
$userIP = $_SERVER['REMOTE_ADDR'];
//Get Timestamp
$myDate = date("Y-m-d H:i:s");//Date in easy-to-read format

$displayForm=false;

if(UMldap($Username,$SSO_Password)){
//set complex string in case there is no `whencreated' field for the username

//User has valid credentials. We are creating a new session variable with the 
user name. This is also a good place to effectively double up your 
authentication security by checking to see if the user name exists in another 
medium, such as a MySQL or Oracle table.
$_SESSION['USERCMS'] = $Username;

//The login is a smashing success, so redirect the user to the protected page.
$MM_redirectWithSuccess = "Successful_login.php";
header("Location: ". $MM_redirectWithSuccess );

} else {
//We can't log the user in, so display the login form again
$displayForm=true;
}

//unbind
ldap_unbind($ldapconn);

//*************************************
}//end POST check

?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" >

<head>
<title>LDAP Login Form</title>
</head>
<body>
<h1>Login</h1>
<?php

//—————————————————————————-
//Form variables to display previously filled out fields
$displayForm=true;
$ssoname=";
$ssopass=";
//—————————————————————————-

//Display the login form
if ($displayForm){//Display the request form
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" id="login" 
name="login">

UserID:
<input type=text size=30 name="ssoname" maxlength=30 />

Password:
<input type=password size=30 name="ssopass" maxlength=30 />
<br />

<button type="submit" value="submit" name="submit" >Logon</button>

</form>

<?php
}
?>

<!– Javascript to move the cursor to the Username form field. This is a small 
convenience to the user. –>
<script type="text/javascript" language="JavaScript">
document.forms['login'].elements['ssoname'].focus();
</script>

</body>
</html>


salam

~ leli ~

Kirim email ke