Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php and unidata

Status
Not open for further replies.

ScottSIT

Technical User
Mar 19, 2007
20
US
I've setup a simple php script that authenticates to an ldap server then displays information in our unidata db on a webpage. The webpage gets updated about every 5 min.

Currently to do this I've setup a cronjob to run a unibasic subroutine that lists data in the db to a file and then ftp's the file to the webserver. From there I've scheduled another cronjob that inserts the file into a mysql database. Finally I use the Ajax method with a simple timed script to refresh the data on the page every few minutes.

While this may work, it is very convoluted. I've read about the PDO_IBM mod for php, but my question is, does anyone have any helpful tips on how to actually do it or any words of wisdom. If I could I'd like to stick with php. Someone mentioned using JDBC and uniobjects to connect to the unidata db through the unirpc port, I haven't looked into that though.

thanks.
 
provided the database server and the ldap server are both available to your web server then i see no reason why php cannot intermediate the data transfer itself rather that relying on filedrops.

you would still need a cronjob to run the php script of course.

i have not used the PDO_IBM module but I use PDO for all my websites now and find it both stable and easy to use.
 
what language have you used to connect to unidata?

I found this
here
Code:
try {
       $dbh = new PDO("u2:dbtype=ud;host=localhost;acct=demo", "my_name", "my_pwd");
} catch (PDOException $e) {
       $ dbh = null;
       echo 'Connection failed: ' . $e->getMessage();
}
 
that looks fine in the abstract (except i would remove the space between $ and dbh in the catch block).

there is no unidata driver for PDO provided in the php distro, so you will have to write and compile one on your own. there is a tutorial here that might assist you

The source code for the driver is also available on that site.

alternatively you could set up an odbc connection to the unidata server (you will need to download and install an ODBC driver for unidata). you can then use odbc_* 'native' functions to connect and process your query or use the PDO interface.
 
Hello,

Are you creating a XML file..?
Which version of UniData do you run..?
I see that you have posted on the Novell forums, so i can deduct that the LDAP authentication you mentioned is done through eDirectory using LDAP, am i correct..? If so, would you mind giving me some tips on how it was accomplished..?


Thanks
 
I haven't posted anything on the Novell forums about LDAP authentication, that was the easy part. You have to compile PHP with the -ldap option. After that you are good to go. If you don't want to use a certificate file, you must disable by putting "TLS_REQCERT never", in your ldap.conf file. Even if the webserver is not the ldap.server, you must put this in the ldap.conf file, if you don't want to use a certificate file. On windows put it "C:\openldap\sysconf\ldap.conf" and on linux "/etc/ldap.conf". Then you can use a simple script like this.
Code:
<?php
ldap_bind("ldaps://server.com","user","pass") 
?>


After some research I've found a way to connect to Unidata using php...and java. I'm not done getting all the elements together, but I don't expect any difficult problems. I was able to successfully connect to a none ODBC compliant Unidata db using Uniobjects and JAVA. By none ODBC compliant I mean the tables are not in SQL view, you could use Visual Schema Generator(VSG) to convert your unidata tables to SQL view and then just use JDBC/ODBC to connect to your unidata db. Download the Uni Development Kit from here. Also get the Java Developer's Guide.
With those two tools and a simple java script you can connect to a unidata db.
Code:
import asjava.uniobjects.*;
import asjava.uniclientlibs.*;
import java.io.*;
public class UOJtest
{
public static void main( String[] argv)
{
UniJava uJava = new UniJava();
System.out.println("Version number = " +
uJava.getVersionNumber() );

try {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	UniSession uSession = uJava.openSession();
	uSession.connect( "host", "user", "pass", "path_to_valid_account");
	UniCommand runCmd = uSession.command( "LIST CUSTOMERS" );
	try { 
		runCmd.exec(); 
		int reply = runCmd.getSystemReturnCode();
		System.out.println(reply);
		} catch (Exception er) { 
					System.out.println("Exception cmd:" + er);
					}

	System.out.println("wait...");

	try { 
		String timer = in.readLine(); 
		} catch (Exception ea) {
					System.out.println("Exception caught: " + ea) ;
  		         ea.printStackTrace() ;
					}
	uSession.disconnect();
	} catch (UniSessionException e ) {
				System.out.println("Session Exception: " + e );
				}
	}
}
Excuse the code, it was used as a proof of concept, but it does work. The last element is to tie all this into PHP. Well using this little tutorial you should be able to embed the UniObjects methods into php. I have not had a change to put all the pieces together, but I can't imagine why it wouldn't work.

Well there you have it. Connecting to a Unidata db using PHP and JAVA.
Here is another resource i found along the way:PickWiki
 
Cool,

Let me ask you this:
Is the UniData part of your ERP..? and What version of UniData are you running..?

The version is very important for the code. UniData 6.x doesnt have connection spooling so that would requiere RedBack intervention and RedBack objects.

Version 7.x does have connection spooling so RedBack is not needed at all.

On a test machine i have i did something like what you have, but for .NET, it created a XML file then the DataGrid was binded to it. But the code would not work on UniData 6.x.

Thanks for your reply..
 
UniData version 7.1, I'm not sure that this method wouldn't work on an earlier version. As long as the UniRPC daemon is running, this should work. I haven't tested this assumption though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top