RE: [PHP] Re: correct session format?
--On Monday, June 23, 2003 08:30:19 AM -0600 Johnson, Kirk [EMAIL PROTECTED] wrote: So what is the diffirent between : session_start (); $_SESSION['eventid'] = 'arma2'; and session_start (); session_register('arama2'); Use the first method to create session variables when register_globals is off in the php.ini file. Use the second method when it is On. http://www.php.net/session Kirk First, there is a bit of a coding error here. The two examples should be: session_start (); $_SESSION['eventid'] = 'arma2'; and session_start (); session_register('eventid'); Second, the documentation indicates that if you turn off register globals you must us the super global $_SESSION[]. But, it later says that $_SESSION[] and session_register() set the same values. (It does talk about a problem with this in 4.2.3 that is fixed in 4.3) My question is what is the effect of mixing these two techniques. For example with register globals off should: session_start (); session_register('eventid'); $_SESSION['eventid'] = 'foo'; Does the session_register() hurt? What is the interaction? The larger question for us a PRIDE is we have quite a bit of code that assumes register globals is on and we are doing new development where we would like to the the super global $_SESSION[] support instead of the older techniques. What are the consequences of mixing the two techniques? Thanks in advance, Bill +--- | Bill MacAllister | Senior Programmer, Pride Industries | 10030 Foothills Blvd., Roseville CA 95747 | Phone: +1 916.788.2402Fax: +1 916.788-2540 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem wit doing ldap_add and modify in same script
--On Wednesday, February 26, 2003 06:05:20 PM -0500 Jim Greene [EMAIL PROTECTED] wrote: So you suggest turning the $info into an array... How would I go about using the: No, I don't suggest turning the $info into any array. It already is an array. Quoting from the www.php.net documentation: An array in PHP is actually an ordered map. So, in PHPese $foo['key'] is an array reference. What I suggest is that you need to initialize it before you reuse the $info name in a different context. Bill $info[objectClass][0]=posixAccount; $info[objectClass][1]=top; In the array ? Thanks :) On Wed, 2003-02-26 at 17:36, Bill MacAllister wrote: Looks to me like a judiciously place $info = array(); would do wonders. Bill --On Wednesday, February 26, 2003 08:23:39 AM -0500 Jim Greene [EMAIL PROTECTED] wrote: Strange problem: Taking the 2 halfs of the scripts (the section to update uidNumber and the one to add the user) and combining them causes an error: Fatal error: ldap_add() [http://www.php.net/function.ldap-add]: Unknown attribute in the data in /home/jwgreene/ldap-add.php on line 68 Yes doing them as 2 seperate scripts works fine. I did read something about not being able to do a modify, and add in the same statment, so I do a ldap_unbind after the completion of the first. Still does the same thing. Any help would be appreciated.. Thanks ?php // LDAP variables $ldaphost = ldap.server; // your ldap servers $ldapport = 389; // your ldap server's port number $ldaprdn = cn=Directory Manager; // ldap rdn or dn $ldappass = test123; // associated password $dn2=uid=default, ou=Users, dc=megalink, dc=net; // Connecting to LDAP $ldapconn = ldap_connect( $ldaphost, $ldapport ) or die(Could not connect to LDAP server.); // connect to ldap server if ($ldapconn) { // binding to ldap server $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); // verify binding if ($ldapbind) { echo LDAP bind successful...\n; $result=ldap_search($ldapconn,ou=Users,dc=megalink,dc=net , u id=default); $info = ldap_get_entries($ldapconn, $result); $defaultUid = $info[0][uidnumber][0]; //print $defaultUid; //print $info[0][uidnumber][0]; $newUid=$defaultUid+1; print $newUid\n; $newinfo[uidNumber]=$newUid; ldap_modify($ldapconn,$dn2,$newinfo); echo LDAP Modify successful...\n; ldap_unbind($ldapconn); } else { echo LDAP bind failed...; } } //Second half of script *works by itself* $dn=cn=Directory Manager; $bindPassword = test123; $mySalt = substr( ereg_replace([^a-zA-Z0-9./],, crypt(rand(1000,), rand(10,99))), 2, 2); $password = crypt(test123,$mySalt); $info[loginShell]=/bin/false; $info[uidNumber]=1002; $info[gidNumber]=100; $info[objectClass][0]=posixAccount; $info[objectClass][1]=top; $info[uid]=test2; $info[gecos]=test; $info[cn]=test2; $info[homeDirectory]=/home/test1; $info[userPassword]={crypt}test123; if (($ldap = ldap_connect(ldap.server,389))) { echo Bind Good...\n; } else { echo Connection Failed...\n; } if (($res = @ldap_bind($ldap, $dn, $bindPassword))) { ldap_add($ldap, uid=test2, ou=Users, dc=megalink, dc=net, $info); echo User Added...\n; } else { echo Addition Failed...\n; } ? Jim G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php + | Bill MacAllister | 14219 Auburn Road | Grass Valley, CA 95949 | Phone: 530-272-8555 -- [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@ Jim Greene Unix Systems Administrator / Security Engineer Oxford Networks www.oxfordnetworks.com Dial-Up - Colo - Web Hosting - Bandwidth [EMAIL PROTECTED] Working with UNIX is like wrestling a worthy opponent. Working with Windows is like attacking a small whining child who is carrying a .38. [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@ + | Bill MacAllister | 14219 Auburn Road | Grass Valley, CA 95949 | Phone: 530-272-8555 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] query to Active Directory
Hello, Should start off my saying I do not know about Active Directory specifically, but I have used the PHP LDAP support a lot against other directory servers. What I see straight off is that $user_dn does not look like a distinguished name. I would have expected something like: $user_dn = uid=username,ou=people,dc=mydomain,dc=myschools,dc=org; Also, while you can bind as someone, you may not need to. Just to see if you can get anything back you might try binding anonymously and just printing something the common name. Finally, it can really be helpful to test your queries with a simple ldap tool like ldapsearch. If you have access to a Linux box somewhere ldapsearch is just part of the tool set. Bill --On Tuesday, February 25, 2003 10:06:21 PM -0500 Ezra Nugroho [EMAIL PROTECTED] wrote: This one is really puzzling... It has taken me days.. I need to do an LDAP search to an Active Directory server. I was able to connect and bind to the server fine, but my searches are always in vain. OK, here we go: box name: mydomain-71.mydomain.myschools.org domain name: mydomain.myschools.org user to search: [EMAIL PROTECTED] (names and and passwords are of course ficticious) my code: ? $user_dn = [EMAIL PROTECTED]; $base_dn = dc=mydomain,dc=myschools,dc=org; $server = mydomain-71.mydomain.myschools.org; echo $conn = ldap_connect($server); echo AUTH: . $bind = ldap_bind($conn, $user_dn,password); $user = ez; $filter = (|(name=$name*)(displayname=$name*)(cn=$name*)); $res = ldap_search($conn,$base_dn,$filter); $info = ldap_get_entries($conn, $res); print_r($info); ? it gives me: Resource id #1 AUTH: 1 Warning: LDAP: Unable to perform the search: can't contact LDAP server in ldap_test.php on line 16 Warning: ldap_get_entres(): supplied argument is not a valid ldap result resource blah blah... Now, I was able to connect and authenticate to it, but why ldap_search() says that I can't connect to it? If I change $base_dn to dc=mydomain-71,dc=mydomain,dc=myschools,dc=org; The error message is changed to : Unable to perform the search: No such object in ldap_test.php on line 16. It doesn't complain about not being able to connect anymore! But of course the search fails because the domain really is only mydomain.myschools.org. What on earth did I do wrong?? Thanks, - This mail sent through IMP: http://horde.org/imp/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php + | Bill MacAllister | 14219 Auburn Road | Grass Valley, CA 95949 | Phone: 530-272-8555 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem wit doing ldap_add and modify in same script
Looks to me like a judiciously place $info = array(); would do wonders. Bill --On Wednesday, February 26, 2003 08:23:39 AM -0500 Jim Greene [EMAIL PROTECTED] wrote: Strange problem: Taking the 2 halfs of the scripts (the section to update uidNumber and the one to add the user) and combining them causes an error: Fatal error: ldap_add() [http://www.php.net/function.ldap-add]: Unknown attribute in the data in /home/jwgreene/ldap-add.php on line 68 Yes doing them as 2 seperate scripts works fine. I did read something about not being able to do a modify, and add in the same statment, so I do a ldap_unbind after the completion of the first. Still does the same thing. Any help would be appreciated.. Thanks ?php // LDAP variables $ldaphost = ldap.server; // your ldap servers $ldapport = 389; // your ldap server's port number $ldaprdn = cn=Directory Manager; // ldap rdn or dn $ldappass = test123; // associated password $dn2=uid=default, ou=Users, dc=megalink, dc=net; // Connecting to LDAP $ldapconn = ldap_connect( $ldaphost, $ldapport ) or die(Could not connect to LDAP server.); // connect to ldap server if ($ldapconn) { // binding to ldap server $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); // verify binding if ($ldapbind) { echo LDAP bind successful...\n; $result=ldap_search($ldapconn,ou=Users,dc=megalink,dc=net, u id=default); $info = ldap_get_entries($ldapconn, $result); $defaultUid = $info[0][uidnumber][0]; //print $defaultUid; //print $info[0][uidnumber][0]; $newUid=$defaultUid+1; print $newUid\n; $newinfo[uidNumber]=$newUid; ldap_modify($ldapconn,$dn2,$newinfo); echo LDAP Modify successful...\n; ldap_unbind($ldapconn); } else { echo LDAP bind failed...; } } //Second half of script *works by itself* $dn=cn=Directory Manager; $bindPassword = test123; $mySalt = substr( ereg_replace([^a-zA-Z0-9./],, crypt(rand(1000,), rand(10,99))), 2, 2); $password = crypt(test123,$mySalt); $info[loginShell]=/bin/false; $info[uidNumber]=1002; $info[gidNumber]=100; $info[objectClass][0]=posixAccount; $info[objectClass][1]=top; $info[uid]=test2; $info[gecos]=test; $info[cn]=test2; $info[homeDirectory]=/home/test1; $info[userPassword]={crypt}test123; if (($ldap = ldap_connect(ldap.server,389))) { echo Bind Good...\n; } else { echo Connection Failed...\n; } if (($res = @ldap_bind($ldap, $dn, $bindPassword))) { ldap_add($ldap, uid=test2, ou=Users, dc=megalink, dc=net, $info); echo User Added...\n; } else { echo Addition Failed...\n; } ? Jim G -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php + | Bill MacAllister | 14219 Auburn Road | Grass Valley, CA 95949 | Phone: 530-272-8555 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorting Arrays
Hello, I am running PHP 4.2.2 on an Alpha Linux system. The array sorting functions don't seem to be doing anything, i.e. pass an array in and get exactly the same thing back. I have tried to isolate the problem by just cutting a simple example out of the documentation, for example the asort example, and it still doesn't work. Is there something I am missing in the config. Note, sorting works fine on an older Alpha Linux system running PHP 4.0.5. Suggestions will be heartily welcomed. Thanks, Bill + | Bill MacAllister | 14219 Auburn Road | Grass Valley, CA 95949 | Phone: 530-272-8555 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] printing
The way that I do it on Linux is to generate TeX output, invoke TeX using system(), and then just lpr the output to the printer. The current production system that I am using actually uses a perl script invoked from a php script, really ugly, but I had the perl script from another project. Here is a PHP example: $tex_file = /tmp/file.tex; $dvi_file = /tmp/file.dvi; $fp = fopen ($tex,w); fputs ($fp, This is a short story.\n); fputs ($fp, \\end\n); fclose($fp); system (tex --output-directory /tmp $tex_file $log_file); system (dvips -P el4050 $dvi_file); You have to understand TeX/LaTeX. The good news is that if you use TeX you will end up with output that the fools that use Crystal Reports will drool over. Bill --On Tuesday, August 14, 2001 2:47 PM +0100 Fernando Avila [EMAIL PROTECTED] wrote: Hello Matthew, Friday, August 10, 2001, 8:55:24 PM, you wrote: ML If you run windows, then see: ML http://www.php.net/manual/en/ref.printer.php ML -Original Message- ML From: Fernando Avila [mailto:[EMAIL PROTECTED]] ML Sent: Friday, August 10, 2001 10:18 AM ML To: [EMAIL PROTECTED] ML Subject: [PHP] printing ML Hello php-general, ML I was thinking about my problem about printing reports ML CAn i do something like connecting a printer to the server where php ML and mysql runs.. And when someone send the comand to print the quote ML get printed in the server's printer? ML if it's posible maybe i will be albe to print a good quote And if i run linux? because I have a redhat 6.2 server Thanks -- Best regards, Fernandomailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] +--- | Bill MacAllister, Senior Programmer | PRIDE Industries | 10030 Foothills Blvd., Dept 1150 | Roseville, California 95747 | Phone: +1 916-788-2402 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]