• ×
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
  • ×
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
Guidelines
Here is the solution to configure HP FutureSmart Printers with Kiwi Syslog Server Click here to view the instructions!
Check some of the most frequent questions about Instant Ink: HP INSTANT INK, HP+ PLANS: INK AND TONER.


Check out our WINDOWS 11 Support Center info about: OPTIMIZATION, KNOWN ISSUES, FAQs AND MORE.
HP Recommended
HP PageWide Pro 477dw Multifunction Printer
Other

this is a littel PHP work to use ldap with php7.4 and STARTTLS.

 

 

Spoiler

<?php
if(isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
} else {
?>
<form action="#" method="POST">
<label for="username">Username: </label><input id="username" type="text" name="username" />
<label for="password">Password: </label><input id="password" type="password" name="password" />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
}

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$ldap="ldap://10.140.10.1:389";
//$username="administrator@example.net";
//$password="aiweiK5ee";
$ds=ldap_connect($ldap);
$ldapbind=false;

if(ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "<p>1 - OK</p><br>";
if(ldap_set_option($ds, LDAP_OPT_REFERRALS, 0)) {
echo "<p>2 - OK</p><br>";
if(ldap_start_tls($ds)) {
echo "<p>3 - OK</p><br>";
$ldapbind = @ldap_bind($ds, $username, $password);
} else { echo "<p>1 - ERROR</p><br>"; }
} else { echo "<p>2 - ERROR</p><br>"; }
} else { echo "<p>3 - ERROR</p><br>"; }

// ldap_close($ds);
if(!$ldapbind) {
echo "<p>4 - ERROR</p><br>";
} else {
$filter="(&(objectClass=user)(objectClass=person)(objectClass=organizationalperson))";
$result = ldap_search($ds,"CN=Users,DC=example,DC=net",$filter);
ldap_sort($ds,$result,"samaccountname");
if ( $result == "" ) { echo "<p>result is nothing!</p><br>"; } else { echo "<p>result erfolgreich!</p><br>"; }
$info = ldap_get_entries($ds, $result);
if ( $info["count"] == 0 ) { echo "<p>info leer!</p><br>"; } else { echo "<p>info erfolgreich!</p><br>"; }
for ($i=0; $i<$info["count"]; $i++) {
if ( $info["count"] < 1 ) {
break;
}
echo "<br>" . $info[$i]["count"] . "," . $info[$i]["distinguishedname"][0] . "<br>";
echo "cn: ".$info[$i]["cn"][0]."<br>givenname: ".$info[$i]["givenname"][0]."<br> sn: ".$info[$i]["sn"][0]."<br> sAMAccountName: ".$info[$i]["samaccountname"][0]."<br>";
echo "c: ".$info[$i]["c"][0]."<br>co: ".$info[$i]["co"][0]."<br> l: ".$info[$i]["l"][0]."<br>";
echo "postalcode: ".$info[$i]["postalcode"][0]."<br>streetaddress: ".$info[$i]["streetaddress"][0]."<br> telephonenumber: ".$info[$i]["telephonenumber"][0]."<br>";
echo "mail: ".$info[$i]["mail"][0]."<br>memberof: ".$info[$i]["memberof"][0]."<br> st: ".$info[$i]["st"][0]."<br>";
//$sr = ldap_list($ds, $basis_dn, "memberof=*", $nur_dieses);
//echo '<pre>';//var_dump($info);//echo '</pre>';//$userDn = $info[$i]["distinguishedname"][0];
}
echo "<p>4 - OK<br>";
}
@ldap_close($ds);
?>

 

 

this works with cn with email and with Domain\username 

this is so simple that it is beyond me why this setting is so faulty.

 

† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the <a href="https://www8.hp.com/us/en/terms-of-use.html" class="udrlinesmall">Terms of Use</a> and <a href="/t5/custom/page/page-id/hp.rulespage" class="udrlinesmall"> Rules of Participation</a>.