krvam where is your AD connection string? - IE HOW are you connecting to AD in the call?
$user = $_SERVER['AUTH_USER'];
Above this code will (per my understanding) store the local authorized user as a var $user. I posted back in 1.6 an AD pass thru mod (prior to plugins being a thing) and this code was in it.