I created my first PHP script that uses IBM Toolbox
for Java classes to access the iSeries. I'm using the
open source version of IBM Toolbox for Java (JTOpen
4.5) and running my PHP scripts in Apache Jakarta
Tomcat 5.0.27.  Running PHP scripts in Tomcat and
using Toolbox classes in PHP scripts is made possible
by JSR 223.

The sample provided here is mostly to show people what
the code looks like. First, here's an ordinary Java
program that checks to see if a user has a valid name
and password on an iSeries.

import com.ibm.as400.access.*; 
public class Authenticate {
 public static void main (String args[]){ 
  try{

   //Set the iSeries name, user name, and password.   
   String system="myiSeries";
   String name="myname";
   String password="mypassword";

   //Create a connection to the iSeries.
   AS400 oursystem = new AS400(system, name,
password); 

   //Authenticate the user and respond to the outcome.
   if (oursystem.authenticate(name, password) ==
true){
     System.out.println("valid user");
   } else {
     System.out.println("invalid user");
   }

  } catch (Exception e) {
   System.out.println("error");
  }
 }              
}

Of course, replace 'myiSeries' with the network name
of your iSeries, replace 'myname' with your iSeries
user profile name, and replace 'mypassword' with your
iSeries password.    

Now here's a PHP script in a Web page that does the
same thing:

<html>
<head></head>
<body>
 <p>Test user authentication on an iSeries.</p>
 <?php
  try {
 
   //Set the iSeries name, user name, and password.
   $clsSystem = new Java("java.lang.String",
"myiSeries");
   $clsUser = new Java("java.lang.String", "myname");
   $clsPassword = new Java("java.lang.String",
"mypassword");

   //Create a connection to the iSeries.
   $iSeries = new Java("com.ibm.as400.access.AS400",
$clsSystem, $clsUser, $clsPassword);
 
   //Authenticate the user and respond to the outcome.
   $uservalid = $iSeries->authenticate($clsUser,
$clsPassword);
   if ($uservalid==true) {
     echo("valid user");
   } else {
     echo("invalid user");
   }

  } catch (Exception $e) {
   echo("error."); 
  }
 ?>
</body>
</html>

I can now use PHP to process a login form,
authenticate the user on the iSeries, and start a
session to save the user's name and password for later
interaction with the iSeries.  No need to write
Servlets or JSPs. 

Later,
Kelly 


                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.