Connect to ldap through coldfusion - php

I am trying to connect to LDAP server using below Coldfusion code. But I get an error "Authentication failed:[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C9, comment: AcceptSecurityContext error, data 52e, v23f0 ]"
<cfldap
action = "Query"
server = "xxxx.edu"
attributes = "*"
name = "result"
password = "yyy"
port = "000"
start = "cn=xxx,ou=xxx,dc=xx,dc=xx,dc=edu"
username = "xxx">
Are the parameters used in the above cfldap tag are correct or do I need to add any other parameters? Does this issue relate to SSL certificate? Any idea what should I use in "start"?
I have successfully connected to LDAP using php using the same parameter values
but the same values when used are throwing an error in Coldfusion? Please suggest.
Thanks in Advance

Related

cURL error [0]: Failed to connect to 127.0.0.1 port 8545: Connection refused

I am using laravel package(furqansiddiqui/erc20-php) for erc20 token transfer, But i am getting error when execute the code
$geth = new EthereumRPC('127.0.0.1', 8545);
$erc20 = new ERC20($geth);
$token = $erc20->token("0x05f4a42e251f2d52b8ed15e9fedaacfcef1fad27");
var_dump($token->name()); // string(7) "Zilliqa"
Make sure to run geth by --rpc parameter
geth --rpc
As easier way to connect to Ethereum network, you can use https://infura.io
Infura support mainnet and testnets (rinkeby, ropsten, kovan, goerli), thats good for development.

WHM API: Find cPanel user by domain

I'm working on a WHM API and want to find the cPanel username by passing the domain name.
NOTE: I've the credentials of WHM.
There is no such documentation exists here https://documentation.cpanel.net/pages/viewpage.action?pageId=1507786
So, is there a way to achieve do so?
Update:
Now, I'm using xmlapi.php and here is what I tried so far.
require_once(base_path() . "/vendor/cpanel_api/xmlapi.php");
$ip = env('SERVER_IP', "127.0.0.1"); //your server's IP
$xmlapi = new \xmlapi($ip);
$xmlapi->password_auth(env('CPANEL_USER', "root"),env('CPANEL_PASSWORD', "")); //the server login info for the user you want to create the emails under
$xmlapi->set_output('json');
$xmlapi->set_debug(1);
$params = array('domain'=>$domain, 'searchtype'=>'domain'); //quota is in MB
$res = json_decode($xmlapi->api2_query('root', "listaccts", "", $params), true);
print_r($res);
in $xmlapi->api2_query method, there are 4 arguments
cPanel Username
WHM Module Name
Function under the Given Module in step 2
parameters, that'll be passed to the function in step 3
I have to find out the cPanel Username, so, I wrote the 'root' for now. but no success
Please give a try with cPanel API.
Here are the some useful docs of API.
https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2
https://documentation.cpanel.net/display/SDK/Guide+to+WHM+API+1

Using PHP with IMAP to check POP3 "syntax error"

I am trying to connect to a pop3 email account that is hosted by my website host. My website is a shared host. The email host that I check my emails with windows live is mail.mysite.com with port 110 and it works fine.
Using php and imap I have not had any luck. I did check and my host does have IMAP installed. After that I fought with it for a few hours and learned when imap_open fails it tries 3 more times just for fun. As I started with imap_last_error() as my error checker it was telling me Cannot connect to Mail: Too many login failures Once I figured out what was happening it did not take long to figure out how to get the rest of the errors and then how to turn it off so it does not retry.
Now I am getting syntax error I have tried dozens and dozens different variations of hostname. Below I include 4 so people can see some of the saner things I have tried and the results.
As I am completely new to this I am likely missing something obvious to someone with more experience. I am also open to other ways to go about this. I just want to be able to use a php script to open and read Emails on a particular account. I am not picky about which or what kind of interface. I have been trying IMAP as it is the only one that I have found.
//$hostname = '{mail.mysite.com:110}INBOX'; //array(1) { [0]=> string(49) "[CLOSED] IMAP connection broken (server response)" }
//$hostname = '{mail.mysite.com:110/pop3}INBOX'; //array(1) { [0]=> string(142) "Certificate failure for mail.mysite.com: Server name does not match certificate: /OU=Domain Control Validated/CN=*.websitesource.net" }
$hostname = "{mail.mysite.com:110/pop3/novalidate-cert}INBOX"; //array(1) { [0]=> string(12) "syntax error" }
//$hostname = '{mail.websitesource.net:110/pop3}INBOX'; //array(1) { [0]=> string(12) "syntax error" }
//A temp account for testing
$user = 'a#mysite.com';
$password = '12345678!';
/* try to connect */
$inbox = imap_open($hostname,$username,$password,0,0) or die( var_dump(imap_errors ()) );
//see errors at top of code, current error 'syntax error'
You are using the wrong variable. Replace $username with $user
$inbox = imap_open($hostname,$user,$password,0,0) or die( var_dump(imap_errors ()) );
Ok I feel rather silly. $username is not the same as $user. When I started with various scripts I did not know about the Certificate problem(different hosts) and somewhere along the lines I no doubt copied part of one test script and part of another and wolla a simple bug that was hidden by the earlier bugs.

Authenticating against LDAP with ApacheDS and PHP

I'm wondering how to authenticate against ApacheDS in PHP. I keep getting a "Invalid Credentials" when I try to log on as a user in a group. I can log in as "uid=admin,ou=system" just fine, but if I try "uid=,ou=consumers,ou=system", it returns "Invalid Credentials".
It is important to note that this is not the full DN of the entry. It's more like "uid=...+gn=...+...,ou=consumers,ou=system". I can search and find this value just fine when bound to the administrator and the API account.
How do I bind to a user just to authenticate and retrieve information on them (like the rest of their attributes and the children of their entry? Here's what I'm doing and failing.
$dn = ldap_connect($serveraddress,10389);
$bn = ldap_bind("uid=".$user.",ou=consumers,ou=system");
var_dump($bn);
var_dump(ldap_error($dn);
Thank you for any help you can provide.
Edit: So I've gotten farther. Why is this a protocol error?
$ds=ldap_connect("192.168.1.126",10389); // must be a valid LDAP server!
if ($ds) ldap_bind($ds,"uid=apiaccess,ou=system",...);
else die("!Can't connect to server");
$userid = md5($user);
$results = ldap_get_entries($ds,ldap_search($ds,"ou=consumers,ou=system","(uid=".$userid.")"));
$result = $results[0]["dn"];
echo $result;
if ($ds) ldap_bind($ds,$result,$pass);
else die("!Can't connect to server");
var_dump(ldap_error($ds));
You need to tell PHP to use LDAPv3.
Before you call ldap_bind, add the following call:
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

FileMaker PHP API Connection Issue

I have recently created a script which should be passed an IP address of the users FM DB Server location, then the script will connect to that server with the given username, password, IP Address and DB Name.
However, no matter what I pass as the IP, it never throws an error.
Is there some form of error handling within the FileMaker PHP API for connection errors?
Thanks in advance!
All the FileMaker API calls return an result object in case of error. You should try this:
Here is an example:
$fm = new FileMaker();
// Set 'hostspec' property using setProperty()
$fm->setProperty('database', $fmConfig['db']);
$fm->setProperty('hostspec', $fmConfig['host']);
$fm->setProperty('username', $fmConfig['user']);
$fm->setProperty('password', $fmConfig['pass']);
$dt = date('m/d/Y H:i:s', $myDate);
$freq = $fm->newFindCommand("myTestLayout_1.0") ;
$freq->addFindCriterion("ModificationTimeStamp", ">".$dt);
$result = $freq->execute();
if (FileMaker::isError($result)) {
$ErrMsg = 'Error code: '.$result->getCode().' Message: '.$result->getMessage();
throw new Exception ($ErrMsg);
}
$foundRecords = $result->getRecords();
echo count($foundRecords)." records";
The server that you're making the calls from needs to have curl support - make sure that's enabled. Best bet is to try locally against your FMS box with the test database - once you've got that working then you can try the remote connection.

Categories