PHP Classes

authentication error: the requested credential user is not defin

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  authentication error: the requested...  >  (Un) Subscribe thread alerts  
Subject:authentication error: the requested...
Summary:authentication error: the requested credential user is not defin
Messages:11
Author:Orion Tiller
Date:2008-02-26 00:26:53
Update:2008-02-27 19:52:37
 
  1 - 10   11 - 11  

  1. authentication error: the requested...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-26 00:26:53
authentication error: the requested credential user is not defined

I am receiving this response only sometimes when i run this not every time. I am using http.php and included sasl.php and all the sasl library files are present. Can anyone see why this code might not be working?




<?php

require_once("http.php");
include('sasl.php');

function http_get( $url ) {
$returnvalue = "";
set_time_limit(0);

$http=new http_class;

$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->follow_redirect=1;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

$error=$http->GetRequestArguments($url,$arguments);

$arguments["RequestMethod"]="GET";

$error=$http->Open($arguments);
if($error) die($error);

$error=$http->SendRequest($arguments);
if($error) die($error);

$headers=array();
$error=$http->ReadReplyHeaders(&$headers);
if($error) die($error);

for(;;) {
$error=$http->ReadReplyBody($body,1000);
if ($error!="" || strlen($body)==0)
break;
$returnvalue .= $body;
}
return $returnvalue;
}

function targus_validate( $fields ) {
$returnvalue = 999;
$reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 24, 25, 26, 27, 29, 30, 31);

$fields['phone'] = str_replace("-", "", $fields['phone']);

$url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=Username&password=PASS&elems=3221";
if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']);
if (isset($fields['email'])) $url .= "&key572=".$fields['email'];
if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']);
if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']);
if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']);
if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']);
if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']);
$url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31";
$url .= "&key3298=13";

$body = http_get( $url );

$reg_error = "<errorcode>(.*)<\/errorcode>";
$reg_value = "<value>(.*)<\/value>";
if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) {
if(preg_match("/$reg_value/siU", $body, $matches)) {
$values = explode(",", trim($matches[1]));
$value = $values[2];

if (in_array($value, $reject_codes)) {
$returnvalue = $value;
} else {
$returnvalue = 0;
}
}
} else {
if ( preg_match("/$reg_error/siU", $body, $matches) ) {
$returnvalue = trim($matches[1]);
}
}

return $returnvalue;
}
?>






HTTP/1.1 200 OK
Connection: close
Date: Mon, 25 Feb 2008 19:35:02 GMT
Server: Apache/2.2.6 (Fedora)
Content-Length: 66
Content-Type: text/plain
Client-Date: Mon, 25 Feb 2008 19:35:03 GMT
Client-Peer: 208.109.29.56:80
Client-Response-Num: 1
X-Powered-By: PHP/5.2.4

authentication error: the requested credential user is not defined



  2. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-02-26 02:56:04 - In reply to message 1 from Orion Tiller
It seems you are accessing a page that requires authentication but you are not specifying the user and password.

After calling GetRequestArguments() function, you need to set the user and password like this:

$arguments["AuthUser"]="some user";
$arguments["AuthPassword"]="some password";

  3. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-26 03:29:49 - In reply to message 1 from Orion Tiller
That did the trick. Thanks so much!

  4. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-27 18:27:03 - In reply to message 3 from Orion Tiller
I am now sometimes getting this response from a different file:

Could not process the SASL authentication step: Basic authentication was finished without success



<?php

require_once("http.php");
include( 'sasl.php' );

function http_get( $url ) {
$returnvalue = "";
set_time_limit(0);

$http=new http_class;

$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->follow_redirect=1;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

$error=$http->GetRequestArguments($url,$arguments);

$arguments["AuthUser"]="Username";
$arguments["AuthPassword"]="Password";
$arguments["RequestMethod"]="GET";

$error=$http->Open($arguments);
if($error) die($error);

$error=$http->SendRequest($arguments);
if($error) die($error);

$headers=array();
$error=$http->ReadReplyHeaders(&$headers);
if($error) die($error);

for(;;) {
$error=$http->ReadReplyBody($body,1000);
if ($error!="" || strlen($body)==0)
break;
$returnvalue .= $body;
}
return $returnvalue;
}

function targus_validate( $fields ) {
$returnvalue = 32;
$reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 26, 27, 29, 30, 31);

$fields['phone'] = str_replace("-", "", $fields['phone']);

$url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=GetSeenMedia&password=aYmh4Ch8&elems=3221";
if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']);
if (isset($fields['email'])) $url .= "&key572=".$fields['email'];
if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']);
if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']);
if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']);
if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']);
if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']);
$url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31";
$url .= "&key3298=13";

$body = http_get( $url );

$reg_error = "<errorcode>(.*)<\/errorcode>";
$reg_value = "<value>(.*)<\/value>";
if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) {
if(preg_match("/$reg_value/siU", $body, $matches)) {
$values = explode(",", trim($matches[1]));
$value = $values[2];

if (in_array($value, $reject_codes)) {
$returnvalue = $value;
} else {
$returnvalue = 0;
}
}
} else {
if ( preg_match("/$reg_error/siU", $body, $matches) ) {
$returnvalue = trim($matches[1]);
}
}

return $returnvalue;
}
?>

  5. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-27 18:38:06 - In reply to message 3 from Orion Tiller
I am now getting this error sometimes but not every time.

authentication error: the requested credential user is not defined




<?php

require_once("http.php");

function http_get( $url ) {
$returnvalue = "";
set_time_limit(0);

$http=new http_class;

$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->follow_redirect=1;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

$error=$http->GetRequestArguments($url,$arguments);

$arguments["AuthUser"]="Username";
$arguments["AuthPassword"]="Password";
$arguments["RequestMethod"]="GET";

$error=$http->Open($arguments);
if($error) die($error);

$error=$http->SendRequest($arguments);
if($error) die($error);

$headers=array();
$error=$http->ReadReplyHeaders(&$headers);
if($error) die($error);

for(;;) {
$error=$http->ReadReplyBody($body,1000);
if ($error!="" || strlen($body)==0)
break;
$returnvalue .= $body;
}
return $returnvalue;
}

function targus_validate( $fields ) {
$returnvalue = 32;
$reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 26, 27, 29, 30, 31);

$fields['phone'] = str_replace("-", "", $fields['phone']);

$url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=Username&password=Password&elems=3221";
if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']);
if (isset($fields['email'])) $url .= "&key572=".$fields['email'];
if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']);
if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']);
if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']);
if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']);
if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']);
$url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31";
$url .= "&key3298=13";

$body = http_get( $url );

$reg_error = "<errorcode>(.*)<\/errorcode>";
$reg_value = "<value>(.*)<\/value>";
if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) {
if(preg_match("/$reg_value/siU", $body, $matches)) {
$values = explode(",", trim($matches[1]));
$value = $values[2];

if (in_array($value, $reject_codes)) {
$returnvalue = $value;
} else {
$returnvalue = 0;
}
}
} else {
if ( preg_match("/$reg_error/siU", $body, $matches) ) {
$returnvalue = trim($matches[1]);
}
}

return $returnvalue;
}
?>

  6. Could not process the SASL...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-27 18:42:24 - In reply to message 2 from Manuel Lemos
I am now getting this error sometimes.

Could not process the SASL authentication step: Basic authentication was finished without success

<?php

require_once("http.php");

function http_get( $url ) {
$returnvalue = "";
set_time_limit(0);

$http=new http_class;

$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->follow_redirect=1;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

$error=$http->GetRequestArguments($url,$arguments);

$arguments["AuthUser"]="Username";
$arguments["AuthPassword"]="Password";
$arguments["RequestMethod"]="GET";

$error=$http->Open($arguments);
if($error) die($error);

$error=$http->SendRequest($arguments);
if($error) die($error);

$headers=array();
$error=$http->ReadReplyHeaders(&$headers);
if($error) die($error);

for(;;) {
$error=$http->ReadReplyBody($body,1000);
if ($error!="" || strlen($body)==0)
break;
$returnvalue .= $body;
}
return $returnvalue;
}

function targus_validate( $fields ) {
$returnvalue = 32;
$reject_codes=array(1, 9, 10, 13, 15, 16, 17, 20, 22, 26, 27, 29, 30, 31);

$fields['phone'] = str_replace("-", "", $fields['phone']);

$url = "https://gwydemo.targusinfo.com/access/query?svcid=9212807267&username=Username&password=Password&elems=3221";
if (isset($fields['phone'])) $url .= "&key1=".urlencode($fields['phone']);
if (isset($fields['email'])) $url .= "&key572=".$fields['email'];
if (isset($fields['address'])) $url .= "&key1390=".urlencode($fields['address']);
if (isset($fields['city'])) $url .= "&key1391=".urlencode($fields['city']);
if (isset($fields['state'])) $url .= "&key1392=".urlencode($fields['state']);
if (isset($fields['zip'])) $url .= "&key1393=".urlencode($fields['zip']);
if (isset($fields['name'])) $url .= "&key1395=".urlencode($fields['name']);
$url .= "&key3221=1,2,3,4,5,6,19,8,20,21,22,23,24,25,26,10,11,14,27,28,29,30,31";
$url .= "&key3298=13";

$body = http_get( $url );

$reg_error = "<errorcode>(.*)<\/errorcode>";
$reg_value = "<value>(.*)<\/value>";
if( preg_match("/$reg_error/siU", $body, $matches) && (trim($matches[1]) == 0) ) {
if(preg_match("/$reg_value/siU", $body, $matches)) {
$values = explode(",", trim($matches[1]));
$value = $values[2];

if (in_array($value, $reject_codes)) {
$returnvalue = $value;
} else {
$returnvalue = 0;
}
}
} else {
if ( preg_match("/$reg_error/siU", $body, $matches) ) {
$returnvalue = trim($matches[1]);
}
}

return $returnvalue;
}
?>

  7. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-02-27 19:08:34 - In reply to message 5 from Orion Tiller
That means that the user name or password are wrong.

The lines to set the parameters $arguments["AuthUser"] and $arguments["AuthPassword"] were just an example. You need to change the "UserName" to the real user name and "Password" to the real password of that user.

  8. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-27 19:25:10 - In reply to message 7 from Manuel Lemos
yes i am using the correct username and password but changed it for posting purposes.

I only get that response sometimes and some other times it works. I am using the correct username and password as was provided to me though, I'll check and make sure.

  9. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-02-27 19:40:19 - In reply to message 8 from Orion Tiller
You need to tell me what are you doing different in the times it does not work.

  10. Re: authentication error: the requested...   Reply   Report abuse  
Picture of Orion Tiller Orion Tiller - 2008-02-27 19:44:25 - In reply to message 9 from Manuel Lemos
That's the thing i am doing nothing different. I run the php file with the same arguments a bunch of times and sometimes it works as expected and others it gives me that response.

 
  1 - 10   11 - 11