Link to home
Start Free TrialLog in
Avatar of lhaluska
lhaluska

asked on

Problem with ldap query to set my cookie variable.

I am trying to set my cookie variable after my ldap query to get the info but it's not working can someone help please? Here is my code..

            $ds=ldap_connect("ldap.cce.cup.com:389");
            $r=ldap_bind($ds);
            $sr=ldap_search($ds, "o=cup.com", 'ntUserDomainId='.$ntUserDomainId , explode(',', 'sn,givenname,telephonenumber,manager,ntUserDomainId,JobTitle,ou,uid,EMPLOYEENUMBER,managerEMPLOYEENUMBER,cn,mailRoutingAddress'));
            $info = ldap_get_entries($ds, $sr);
                  setcookie("EMAIL", $info['uid'], $life, "/", "webres.qweb.cpqcorp.net");
                  setcookie("PHONE", $info['telephonenumber'],$life, "/",  "webres.qweb.cpqcorp.net");
Avatar of hernst42
hernst42
Flag of Germany image

The result of $info should be different than you expect. You might need to use:

setcookie("EMAIL", $info[0]['uid'], $life, "/", "webres.qweb.cpqcorp.net");
setcookie("PHONE", $info[0]['telephonenumber'],$life, "/",  "webres.qweb.cpqcorp.net");


Make a var_dump($info) and check the structure of the result.
Avatar of lhaluska
lhaluska

ASKER

I am confused how do I make a var dump? Sorry for the stupid questions but I am a newbie..
var_dump is a function of php http://www.php.net/var_dump
This is what I am getting...

array(1) { ["count"]=> int(0) }

Notice: Undefined variable: info in C:\Inetpub\wwwroot\ServiceRequest\allpage.php on line 31
Notice: Undefined variable: info in C:\Inetpub\wwwroot\ServiceRequest\allpage.php on line 32
In this case your ldap query didn't found a matching value. Check your ldap query
great thanks I am looking in to it...
I fixxed the ldap query here is my dump but still having problem with my cookie set can you help please. Here is my var dump with the errors for the cookie sets.
array(2) { ["count"]=> int(1) [0]=> array(24) { ["ntuserdomainid"]=> array(2) { ["count"]=> int(1) [0]=> string(17) "AMER:lhaluska" } [0]=> string(14) "ntuserdomainid" ["givenname"]=> array(2) { ["count"]=> int(1) [0]=> string(5) "Louis" } [1]=> string(9) "givenname" ["sn"]=> array(2) { ["count"]=> int(1) [0]=> string(7) "Haluska" } [2]=> string(2) "sn" ["cn"]=> array(2) { ["count"]=> int(1) [0]=> string(13) "LHaluska" } [3]=> string(2) "cn" ["employeenumber"]=> array(2) { ["count"]=> int(1) [0]=> string(8) "111111" } [4]=> string(14) "employeenumber" ["manager"]=> array(2) { ["count"]=> int(1) [0]=> string(45) "uid=bingh@cup.com,ou=People,o=cup.com" } [5]=> string(7) "manager" ["manageremployeenumber"]=> array(2) { ["count"]=> int(1) [0]=> string(8) "07724438" } [6]=> string(21) "manageremployeenumber" ["uid"]=> array(2) { ["count"]=> int(1) [0]=> string(20) "lhaluska@cup.com" } [7]=> string(3) "uid" ["mailroutingaddress"]=> array(2) { ["count"]=> int(1) [0]=> string(32) "lha58825.routing@am2.exch.cup.com" } [8]=> string(18) "mailroutingaddress" ["ou"]=> array(2) { ["count"]=> int(1) [0]=> string(28) "SND Softw&Sols" } [9]=> string(2) "ou" ["telephonenumber"]=> array(2) { ["count"]=> int(1) [0]=> string(15) "+1 888 555 1234" } [10]=> string(15) "telephonenumber" ["count"]=> int(11) ["dn"]=> string(43) "uid=lhaluska@cup.com,ou=People,o=cup.com" } }

Warning: setcookie() expects parameter 2 to be string, array given in C:\Inetpub\wwwroot\ServiceRequest\allpage.php on line 31

Warning: setcookie() expects parameter 2 to be string, array given in C:\Inetpub\wwwroot\ServiceRequest\allpage.php on line 32

ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much it works great...