?
Solved

Problem with ldap query to set my cookie variable.

Posted on 2007-10-01
9
Medium Priority
?
228 Views
Last Modified: 2008-01-09
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");
0
Comment
Question by:lhaluska
  • 5
  • 4
9 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 20004378
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.
0
 
LVL 1

Author Comment

by:lhaluska
ID: 20008127
I am confused how do I make a var dump? Sorry for the stupid questions but I am a newbie..
0
 
LVL 48

Expert Comment

by:hernst42
ID: 20014878
var_dump is a function of php http://www.php.net/var_dump
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:lhaluska
ID: 20017583
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
0
 
LVL 48

Expert Comment

by:hernst42
ID: 20018482
In this case your ldap query didn't found a matching value. Check your ldap query
0
 
LVL 1

Author Comment

by:lhaluska
ID: 20018645
great thanks I am looking in to it...
0
 
LVL 1

Author Comment

by:lhaluska
ID: 20096719
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

0
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 20096880
Base on the vardump the cookies should be able to set with:

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

Author Comment

by:lhaluska
ID: 20096907
Thank you very much it works great...
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question