Php-SSRS DataSource Credentials - php

I'm using a third-party extension in Symfony to connect to SSRS: https://github.com/ChartBlocks/php-ssrs
I need to keep my SSRS datasource as "prompt for credentials" since we are also using another solution that requires that, but I'm unsure how to set the DataSourceCredentials in my solution. I get the error: System.Web.Services.Protocols.SoapException: One or more data source credentials required to run the report have not been specified.
Here's my code in my controller:
$options = [
'username' => $this->getParameter('ssrs_user'),
'password' => $this->getParameter('ssrs_password')
];
$ssrs = new SSRS\Report($this->getParameter('ssrs_server'), $options);
$result = $ssrs->loadReport($this->getParameter('ssrs_base').'/'.$request->get('report'));
$ssrs->setSessionId($result->executionInfo->ExecutionID);
$parameters = json_decode($request->get('parameters'),true);
$ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));
$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV | HTML4.0 | Excel
return $output;
Anyone know what I need to add to pass the DataSourceCredentials?

Found an answer by creating my own method in the Report.php file, until it's updated in the core:
public function setDataSourceCredentials($datasource,$username,$password) {
$this->checkSessionId();
$options = array(
'Credentials' => array(
'DataSourceCredentials' => array(
'DataSourceName' => $datasource,
'UserName' => $username,
'Password' => $password
)
)
);
$result = $this->getSoapExecution()->SetExecutionCredentials($options);
return new ExecutionInfo($result);
}
I call this in my controller before rendering the report:
$ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));
$ssrs->setDataSourceCredentials($this->getParameter('ssrs_datasource'),$this->getParameter('ssrs_sql_user'),$this->getParameter('ssrs_sql_password'));

Related

How can i get my PHP SoapClient to Authenticate with Digest

I currently have a vb.net ASMX web service hosted on IIS along with a PHP page which is calling the web service via a SoapClient.
I need to authenticate the webservice against ActiveDirectory and i figured the easiest way to do this would be to enable Digest Authentication on IIS and allow the user to enter their AD username/password into the PHP page and send this authentication in the SoapHeaders.
I am not really quite sure how to go about this, especially when trying to contact the WSDL (which is also behind the Digest Authentication).
Any help would be appreciated.
Thanks
EDIT: What i've tried:
SERVICE_URL points to http://mypage/service.asmx?wsdl
Attempt 1: User and Pass as MD5
$options = array(
'authentication' => SOAP_AUTHENTICATION_DIGEST,
'realm' => 'myrealm',
'login' => $_SESSION['authUser'],
'password' => $_SESSION['authPass']
);
try { $client = new SoapClient(SERVICE_URL, $options); }
Attempt 2: Auth is the 'user':'realm':'pass' as MD5:
$options = array(
'authentication' => SOAP_AUTHENTICATION_DIGEST,
'login' => $_SESSION['auth']
);
try { $client = new SoapClient(SERVICE_URL, $options); }
You can add headers to your soap client using SoapHeader() class/object (SoapHeader() documentation) and soap object operator __setSoapHeaders() (__setSoapHeaders() documentation).
Your request would look something like this:
<?php
$options = array(
'authentication' => SOAP_AUTHENTICATION_DIGEST,
'realm' => 'myrealm',
'login' => $_SESSION['authUser'],
'password' => $_SESSION['authPass']
);
try {
$client = new SoapClient(SERVICE_URL, $options);
// create and populate header array
$headers = array();
$headers[] = new SoapHeader('MYNAMESPACE',
'authentication',
'SOAP_AUTHENTICATION_DIGEST');
$headers[] = new SoapHeader('MYNAMESPACE',
'realm',
'myrealm');
$client->__setSoapHeaders($headers); // set headers
$client->__soapCall("echoVoid", null); // make soap call
}
?>

How to Integrate SuiteCRM Web to Lead Form with Php..?

<?php
$client = new SoapClient("http://localhost/suiteCRM/service/v2/soap.php?wsdl");
$response = $client->__soapCall("login", array(
"user_auth" =>
array(
'user_name' => 'admin',
'password' => md5('223311'),
'version' => "0.1",
),
"application_name"=>""
)
);
$session_id=$response->id;
echo"Session ID".$session_id;
?>
while i connecting it gives 404 error i need solution how to store form values to suitecrm
You should use rest rather than SOAP.
ideally, your URL will be.
http://localhost/suiteCRM/service/v4/rest.php

PHP SOAP Client giving error at the time of calling a method "SoapFault exception: [s:Receiver] Object reference not set to an instance of an object"

I am completely new to PHP SOAP . After doing some R&D for my problem I got some links of stackoverflow but didn't get the perfect solution.
Here is my problem :
I am creating a SOAP client that will execute a method called GetPassword and It will return an encrypted password with response code '100' if the credentials is correct. In case of wrong credential a response code '101' and the response status will receive.
Here is my code (I am hiding the credentials for security purpose):
$url= "http://bsestarmfdemo.bseindia.com/StarMFFileUploadService/StarMFFileUploadService.svc?wsdl";
$method = "GetPassword";
$error=0;
$client = new SoapClient($url, array('soap_version' => SOAP_1_2 , 'SoapAction'=>'http://tempuri.org/IStarMFFileUploadService/GetPassword'));
$actionHeader= array();
$actionHeader[] = new SoapHeader('http://www.w3.org/2005/08/addressing',
'Action',
'http://tempuri.org/IStarMFFileUploadService/GetPassword');
$actionHeader[] = new SoapHeader('http://www.w3.org/2005/08/addressing',
'To',
'http://bsestarmfdemo.bseindia.com/StarMFFileUploadService/StarMFFileUploadService.svc/Basic');
$client->__setSoapHeaders($actionHeader);
$param = array('MemberId' => 'XXXXX', 'Password' => 'XXXXXXX', 'UserId' => 'XXXXXXX');
try{
$info = $client->__call($method, array($param));
}
catch (SoapFault $fault) {
$error = 1;
}
if($error==1) {
$xml=$fault;
}else{
$xml = $info;
}
echo($xml);
Some couples of days ago I got this error and the error was happening due to the mismatch of parameters. But this time I think the parameters are correct. So may be I am doing some small mistakes.. Please help me to find the mistakes.
If any input needed, please let me know in the comment, I will update.
Please Note : I tested the wsdl URL with the SoapUI software and it is returning perfectly.
The Problem was with Parameter . Just analyze the structure of the Method GetPassword and found that it take only one parameter named 'Param' which is an object and inside the Param object it is taking the values of MemberId', 'Password' , 'UserId'.
So just need to change one line of code.
use
$param =array ('Param' => array('MemberId' => 'XXXXX', 'Password' => 'XXXXXXX', 'UserId' => 'XXXXXXX') );
Instead of
$param = array('MemberId' => 'XXXXX', 'Password' => 'XXXXXXX', 'UserId' => 'XXXXXXX');
and the issue resolved.

PHP SoapClient returns NULL (cakephp)

So, I have following problem:
I am using plugin CakeSoap for get data from SAP.
If I test with my internal link (in house) it is working, but if I try with external link I am geting following error:
"Failed to open stream: Could not connect because the target computer denied the connection." and "I/O warning : failed to load external entity "http://..."
Also, if I try to load this link directly from browser it is working.
I have read all threads on StackOverflow and in my options parameter "trace" is setted to "true"
here is the example of my connection
private function getDataSAP($SAPcustomerID, $SAPdestinationIDS){
$soap = new CakeSoap([
'wsdl' => Configure::read('SAP_WSDL_CUSTOMER'),
'login' => Configure::read('SAP_USERNAME'),
'password' => Configure::read('SAP_PASS'),
'location' => Configure::read('SAP_WS_CUSTOMER'),
]);
//Collect all products from specific user and his destinations
$all_data = [];
foreach($SAPdestinationIDS as $data){
$all_data[] = $soap->sendRequest('ZGetCustomerData', [
'ZGetCustomerData' => [
'ICustomer' => $SAPcustomerID->customer_number,
'ItLocation' => [
'item' => [
'Servloc' => $data->destination_number
]
]
],
]
);
}
$all_destinations = [];
foreach($all_data as $my_containers){
$all_destinations[] = json_decode(json_encode($my_containers->EtLocation->item), true);
}
return $all_destinations;
}
And there are options from my CakeSoap.php file
$options = [
// 'trace' => Configure::read('debug'),
'trace' => true,
'stream_context' => $context,
'cache_wsdl' => WSDL_CACHE_NONE
];
Additional I have tried to make request using SoapUI software and it is working.
So my question is why this link doesnt work in php?
Thank you for helping!

ZF2 Zend\Paginator\Adapter\DbSelect on DB2 i Series

Im creating a Zend APIgility application REST service and having a problem with my fetchAll Mapper function.
I'm connecting to an IBM DB2 database running on an i Series server (AS/400) via DB2 Connect on a Windows Application Server.
My Connection is is made in my local.php as such:
return array(
'db' => array(
'driver' => 'IbmDb2',
'database' => $database,
'username' => $user,
'password' => $password,
'hostname' => $host,
'port' => $port,
'driver_options' => array(
'i5_naming' => DB2_I5_NAMING_ON,
'i5_lib' => 'LIBWEB',
),
),
);
The fetchAll() function in my Mapper class is:
public function fetchAll()
{
$select = new Select('WBRESOURCE');
$paginatorAdapter = new DbSelect($select, $this->adapter);
$collection = new ResourcesCollection($paginatorAdapter);
return $collection;
}
When I hit the DbSelect, ZF2 throws the following DB2 Connect error:
"[IBM][CLI Driver][AS] SQL0204N \"*LIBL.WBRESOURCE\" is an undefined name. SQLSTATE=42704"
Im not sure why its using *LIBL (user defined library list), since I defined the library (SCHEMA) to use as LIBWEB in my connection option.
Thanks in advance!
Rob
Try changing this section:
'driver_options' => array(
'i5_naming' => DB2_I5_NAMING_ON,
'i5_lib' => 'LIBWEB',
Change to":
'driver_options' => array(
'i5_naming' => DB2_I5_NAMING_OFF, <=== change
'i5_lib' => 'LIBWEB',
By using DB2_I5_NAMING_OFF, you should get SQL naming mode. The use of DB2 i5 naming mode will result in things like reliance on a job's library list.
See PHP: db2-connect for some info on the parameter.

Categories