Styli125
04-17-2008, 04:47 PM
Hello All,
I am TRYING to use a SOAP client to process auth. The coding is provided to me as an example, and I have done so but when I try to login it just reloads the page. The page can be found at http://a0950701.uscgaux.info/login/soapclient/php . The expample code is below, Please help! Items with '*****' replaced the reference of the hosting server. FYI this example text works to print when used on the host server. The library is installed on my server.
<?php
/************************************************** *******************
TITLE: eDirectory SOAP Authentication Service Example Script
FILE: soapclient.php
DESC: This is the PHP-based example script for performing
authentication for your website using the eDirectory. This
service uses auxedirectory.org's database to authenticate
Employee ID's (eid) and thier corresponding password.
This service is only accessible if you have been given
permission to use it. Please contact an auxedirectory.org
admin for more information.
************************************************** ********************/
### You must install the NuSOAP PHP library. You can download it at
### http://www.*****.org/dev/files/nusoap.zip
require_once("nusoap/nusoap.php"); ### Change the path to where nusoap.php lives
### Location of SOAP service description
$serverpath ='http://www.*****.org/webservice.php?wsdl';
### Notice the referenced JavaScripts in the <HEAD> tag. These are *required*
?>
<HTML>
<HEAD>
<TITLE>***** SOAP Authentication Service Example</TITLE>
<SCRIPT language='JavaScript' src='http://www.*****.org/lib/md5.js'></SCRIPT>
<SCRIPT language='JavaScript' src='http://www.*****.org/lib/inc.remote.js'></SCRIPT>
</HEAD>
<BODY bgcolor='#FFFFFF'>
<?
if ($pass != '') {
### If TRUE, they submitted the form
### Create the SOAP client
$soap_client = new soapclient($serverpath, 'wsdl');
### Return a proxy object representing the service
$edirectory = $soap_client->getProxy();
### Authenticate the user
$auth = $edirectory->remote_auth( $eid, $pass );
### If a fault occurred (access denied), output error info
if ($edirectory->getError()) {
### Give the reason why authentication failed
print "Authentication FAILED: " . $edirectory->getError() . "<BR>";
### Make sure you exit after erroring
exit;
}
### return value $auth is a hash (associative array). To see it's structure, uncomment this:
//print "<PRE>"; print_r( $auth ); exit;
print "Authentication PASSED<BR>";
### Here is where you'd set your cookie or session variable to maintain a logged-in state
### For this demo, I print out the variables:
print "<PRE>";
print "FullName = '" . $auth['fullname'] . "'<BR>";
print "ShortName = '" . $auth['shortname'] . "'<BR>";
print "FirstName = '" . $auth['firstname'] . "'<BR>";
print "MiddleName = '" . $auth['middlename'] . "'<BR>";
print "LastName = '" . $auth['lastname'] . "'<BR>";
print "NickName = '" . $auth['nickname'] . "'<BR>";
print "Email = '" . $auth['email'] . "'<BR>";
print "District = '" . $auth['district'] . "'<BR>";
print "Division = '" . $auth['division'] . "'<BR>";
print "Flotilla = '" . $auth['flotilla'] . "'<BR>";
### $auth['offices'] is an array. Cycle through and print them out
$i = 0;
foreach( $auth['offices'] as $office)
print "Office " . $i++ . " = '$office'<BR>";
### $auth['comps'] is an array. Cycle through and print them out
$i = 0;
foreach( $auth['comps'] as $comp)
print "Comp " . $i++ . " = '$comp'<BR>";
print "\n";
print "Request:\n" . htmlspecialchars( str_replace("><", ">\n<", $edirectory->request ) ) . "\n\n\n";
print "Response:\n" . htmlspecialchars( str_replace("><", ">\n<", $edirectory->response ) ) . "\n\n\n";
print "Debug:\n" . htmlspecialchars( str_replace("><", ">\n<", $soap_client->debug_str ) ) . "\n\n\n";
print "</PRE>";
/*
Once you have this information (name, email, etc.) you can have some fun:
* Display their name on the page, or forum messages, etc.
* Make access decisions based on Offices held or District, Division, Flotilla
*/
} else {
### No form submitted yet, show it
?>
<center><div align='center'>
<P><font face='arial'>
This site uses the same username and password as<BR>
the <A href="http://www.*****.org/" target="_blank">*****</A>
</font></P>
<!-- BEGIN LOGIN TABLE -->
<CENTER><DIV align="center">
<TABLE border="0" cellspacing="1" cellpadding="0" bgcolor="#808090" width="300"><TBODY><TR><TD>
<TABLE border="0" cellspacing="0" cellpadding="5" width="300" bgcolor="#808090">
<FORM action="<?= $PHP_SELF ?>" name="auth" method="POST">
<TR>
<TD colspan="2" align="center" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000000" size="4"><B>Please Log In</B></FONT>
</TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000077" size="3"><B>Auxiliary Employee ID</B></FONT>
</TD>
<TD align="left" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000000" size="2"><INPUT type="text" name="eid" size="10"></FONT>
</TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000077" size="3"><B>eDirectory Password</B></FONT>
</TD>
<TD align="left" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000077" size="2"><INPUT type="password" name="clearpass" size="10"></FONT>
</TD>
</TR>
<TR>
<TD colspan="2" align="center" valign="middle" bgcolor="#efeffc">
<INPUT type="hidden" name="pass" value="">
<INPUT type="submit" value="Login" name="login" onclick="javascript:SubmitAuth();">
</TD>
</TR>
</TBODY></TABLE>
</FORM>
</TD></TR></TBODY></TABLE>
</DIV></CENTER>
<!-- END LOGIN TABLE -->
<?
} ### end if form submitted
?>
</BODY>
</HTML>
I am TRYING to use a SOAP client to process auth. The coding is provided to me as an example, and I have done so but when I try to login it just reloads the page. The page can be found at http://a0950701.uscgaux.info/login/soapclient/php . The expample code is below, Please help! Items with '*****' replaced the reference of the hosting server. FYI this example text works to print when used on the host server. The library is installed on my server.
<?php
/************************************************** *******************
TITLE: eDirectory SOAP Authentication Service Example Script
FILE: soapclient.php
DESC: This is the PHP-based example script for performing
authentication for your website using the eDirectory. This
service uses auxedirectory.org's database to authenticate
Employee ID's (eid) and thier corresponding password.
This service is only accessible if you have been given
permission to use it. Please contact an auxedirectory.org
admin for more information.
************************************************** ********************/
### You must install the NuSOAP PHP library. You can download it at
### http://www.*****.org/dev/files/nusoap.zip
require_once("nusoap/nusoap.php"); ### Change the path to where nusoap.php lives
### Location of SOAP service description
$serverpath ='http://www.*****.org/webservice.php?wsdl';
### Notice the referenced JavaScripts in the <HEAD> tag. These are *required*
?>
<HTML>
<HEAD>
<TITLE>***** SOAP Authentication Service Example</TITLE>
<SCRIPT language='JavaScript' src='http://www.*****.org/lib/md5.js'></SCRIPT>
<SCRIPT language='JavaScript' src='http://www.*****.org/lib/inc.remote.js'></SCRIPT>
</HEAD>
<BODY bgcolor='#FFFFFF'>
<?
if ($pass != '') {
### If TRUE, they submitted the form
### Create the SOAP client
$soap_client = new soapclient($serverpath, 'wsdl');
### Return a proxy object representing the service
$edirectory = $soap_client->getProxy();
### Authenticate the user
$auth = $edirectory->remote_auth( $eid, $pass );
### If a fault occurred (access denied), output error info
if ($edirectory->getError()) {
### Give the reason why authentication failed
print "Authentication FAILED: " . $edirectory->getError() . "<BR>";
### Make sure you exit after erroring
exit;
}
### return value $auth is a hash (associative array). To see it's structure, uncomment this:
//print "<PRE>"; print_r( $auth ); exit;
print "Authentication PASSED<BR>";
### Here is where you'd set your cookie or session variable to maintain a logged-in state
### For this demo, I print out the variables:
print "<PRE>";
print "FullName = '" . $auth['fullname'] . "'<BR>";
print "ShortName = '" . $auth['shortname'] . "'<BR>";
print "FirstName = '" . $auth['firstname'] . "'<BR>";
print "MiddleName = '" . $auth['middlename'] . "'<BR>";
print "LastName = '" . $auth['lastname'] . "'<BR>";
print "NickName = '" . $auth['nickname'] . "'<BR>";
print "Email = '" . $auth['email'] . "'<BR>";
print "District = '" . $auth['district'] . "'<BR>";
print "Division = '" . $auth['division'] . "'<BR>";
print "Flotilla = '" . $auth['flotilla'] . "'<BR>";
### $auth['offices'] is an array. Cycle through and print them out
$i = 0;
foreach( $auth['offices'] as $office)
print "Office " . $i++ . " = '$office'<BR>";
### $auth['comps'] is an array. Cycle through and print them out
$i = 0;
foreach( $auth['comps'] as $comp)
print "Comp " . $i++ . " = '$comp'<BR>";
print "\n";
print "Request:\n" . htmlspecialchars( str_replace("><", ">\n<", $edirectory->request ) ) . "\n\n\n";
print "Response:\n" . htmlspecialchars( str_replace("><", ">\n<", $edirectory->response ) ) . "\n\n\n";
print "Debug:\n" . htmlspecialchars( str_replace("><", ">\n<", $soap_client->debug_str ) ) . "\n\n\n";
print "</PRE>";
/*
Once you have this information (name, email, etc.) you can have some fun:
* Display their name on the page, or forum messages, etc.
* Make access decisions based on Offices held or District, Division, Flotilla
*/
} else {
### No form submitted yet, show it
?>
<center><div align='center'>
<P><font face='arial'>
This site uses the same username and password as<BR>
the <A href="http://www.*****.org/" target="_blank">*****</A>
</font></P>
<!-- BEGIN LOGIN TABLE -->
<CENTER><DIV align="center">
<TABLE border="0" cellspacing="1" cellpadding="0" bgcolor="#808090" width="300"><TBODY><TR><TD>
<TABLE border="0" cellspacing="0" cellpadding="5" width="300" bgcolor="#808090">
<FORM action="<?= $PHP_SELF ?>" name="auth" method="POST">
<TR>
<TD colspan="2" align="center" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000000" size="4"><B>Please Log In</B></FONT>
</TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000077" size="3"><B>Auxiliary Employee ID</B></FONT>
</TD>
<TD align="left" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000000" size="2"><INPUT type="text" name="eid" size="10"></FONT>
</TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000077" size="3"><B>eDirectory Password</B></FONT>
</TD>
<TD align="left" valign="middle" bgcolor="#efeffc">
<FONT face="Arial, Helvetica" color="#000077" size="2"><INPUT type="password" name="clearpass" size="10"></FONT>
</TD>
</TR>
<TR>
<TD colspan="2" align="center" valign="middle" bgcolor="#efeffc">
<INPUT type="hidden" name="pass" value="">
<INPUT type="submit" value="Login" name="login" onclick="javascript:SubmitAuth();">
</TD>
</TR>
</TBODY></TABLE>
</FORM>
</TD></TR></TBODY></TABLE>
</DIV></CENTER>
<!-- END LOGIN TABLE -->
<?
} ### end if form submitted
?>
</BODY>
</HTML>