I think i solved this myself...
Two files to deal with:
/include/staff/newticket.inc.php
<script type="text/javascript">
// Change to AD lookup
// J. Pastin 9-3-09
// var options = {
// script:"ajax.php?api=tickets&f=searchbyemail&limit=10&",
// varname:"input",
// json: true,
// shownoresults,
// maxresults,
// callback: function (obj) { document.getElementById('email').value = obj.id; document.getElementById('name').value = obj.info; return false;}
// };
// var autosug = new bsn.AutoSuggest('email', options);
//
var name_options = {
script: "userfind.php?maxEntries=10&",
varname: "name",
json: true,
delay: 100,
cache,
callback (obj) {document.getElementById('email').value=obj.info;}
};
var email_options = {
script: "userfind.php?maxEntries=10&",
varname:"mail",
json,
cache,
callback (obj) {document.getElementById('name').value=obj.info;}
};
var email_as=new bsn.AutoSuggest('email', email_options);
var name_as=new bsn.AutoSuggest('name', name_options);
// End Changes
Create /scp/userfind.php, you will need to customize some variables here.
<?php
//Replace this with your AD Domain Controller
$ds=ldap_connect('ldap://mydc.mydomain.com') or die("Couldn't connect to AD!");
//Replace this with a username that has read permissions on your AD
$connect_u = "ad\myUser";
//Replace this with the password of the user
$conect_p="myPass";
//Replace this with the DN of the base OU you want to search
$search_user_dn = "OU=users,DC=my,DC=company,DC=com";
$inforequired = array("displayName","mail");
if (!ldap_bind( $ds, $connect_u, $conect_p) ) {
$error_msg = "Could not bind AD connection<br>";
}
else
{
if (!empty($_REQUEST)) {
$curMail=$_REQUEST;
$curMail = strtolower($curMail);
$curMail.='*';
$filter="(&(mail=$curMail)(objectCategory=person))";
}
elseif (!empty($_REQUEST)) {
$curName=$_REQUEST;
$curName = strtolower($curName);
$curName.='*';
$filter="(&(displayName=$curName)(objectCategory=person))";
}
$user_result = ldap_search($ds,$search_user_dn,$filter,$inforequired);
$user_info = ldap_get_entries($ds,$user_result);
header("Content-Type: application/json");
echo"{\"results\": [";
$arr=Array();
if (count($user_info) > $_REQUEST)
{
$max=$_REQUEST;
}
else
{
$max=count($user_info);
}
for ( $i=1; $i<$max; $i+=1)
{
if (!empty($_REQUEST)) {
$arr= "{\"id\": \"".$i."\", \"value\": \"".$user_info."\", \"info\": \"".$user_info."\"}";
}
elseif (!empty($_REQUEST)) {
$arr= "{\"id\": \"".$i."\", \"value\": \"".$user_info."\", \"info\": \"".$user_info}";
}
?>