Nodejs trying to connect to a database and pulls me hostinger this error before i use http://www.freemysqlhosting.net/ was similarly placing the host, user, pass and name of the database and did not erro I think that is the port but idk .. I'm using: app.listen (process.env.PORT || 3000)
So I'm doing:
var connection = mysql.createConnection ({
host: 'mysql.hostinger.es',
user: 'XXXXX',
password: 'XX',
database: 'XXX',
});
Error I get:
It tells you that it couldn't resolve mysql.hostinger.es
Check it's the good hostname or try to set directly the IP address.
Related
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.
I'm fairly new to using PHP to connect to a SQL Database and I am having an issue where I receive this error message, when trying to connect to a database via sqlsrv_connect():
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I've followed the instructions found here and have placed this extension; php_sqlsrv_53_nts.dll, into the php.ini file. Phpinfo() shows sqlsrv as enabled on the web server but I still receive the same error when trying to connect to the data source.
Below is the code I am using:
$db_server = 'tcp:192.168.0.1';
$db_credentials = array('UID' => 'Domain\Username', //SQL Server UID
'PWD' => 'Password', //SQL PW
'Database' => 'ThisDatabase', //Name of the database
'CharacterSet' => 'UTF-8',
'ConnectionPooling' => 'False',
'LoginTimeout' => 60); //Number of Seconds before fail
$db_connect = sqlsrv_connect($db_server, $db_credentials);
//Check the connection to the SQL Database to see if it's valid or else display errors.
if ($db_connect === false) {
die(print_r(sqlsrv_errors(), true));
} else {
echo "Success: Connected to database.";
};
I'm completely stumped, so any help will be useful!
As suggested by #Terminus, installing either the SQL Server driver or SQL Native Client driver on the web server resolves the problem.
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
I am trying to connect my custom mysql database to Auth0.But i am getting the following error
[Error] ECONNREFUSED - connect ECONNREFUSED 127.0.0.1:3306
my code is,
function create (user, callback) {
var connection = mysql({
host : 'localhost',
user : 'db_user',
password : 'db_password',
database : 'db_name'
});
connection.connect();
var query = "INSERT INTO users SET ?";
var insert = {
password: bcrypt.hashSync(user.password, 10),
email: user.email
};
connection.query(query, insert, function (err, results) {
if (err) return callback(err);
if (results.length === 0) return callback();
callback(null);
});
}
The script runs on Auth0 servers, so localhost would be auth0 itself. You need to use a network address that is reachable from Auth0 servers.
You can check ngrok for bridging your own dev server with a cloud service (like Auth0).
You get that error because Auth0 (Where the script runs) cannot reach your DB server. When the script runs Auth0 goes to localhost, in this case, the same Auth0, hence your connection is refused. You will have to:
bridge your connection with ngrok as Eugenio Pace said, exposing your DB to the internet (thus making it visible to Auth0)
And change the var connection attributes accordingly. (the server url and the user creds)
You can also check Auth0 documentation here
My project is to make a module enrollment system for our university. So I contacted the IT people in my university for details to authenticate the students into the system. We are developing the system using the existing university login. They gave me some LDAP information, I don't know the usage of that.
I'm using PHP,Mysql on an Apacha server.
How can I authenticate a user logging into my system, given his userid and password with the LDAP information.
Given below is the LDAP information(i have changed the domain name etc.)
LDAP information for blueroom.ac.uk domain
LDAP Host : ad.blueroom.ac.uk
LDAP port no: 389
BASE DN : ou=bluebird, dc=bluebird, dc=ac, dc=my
LDAP account to bind : cn = kikdap, ou=servacc, dc=bluebird,dc=ac,dc=uk
LDAP account password : ********
Attribute : sAMAccountName
The general procedure would be (relevant ext/ldap php commands in brackets):
connect to LDAP server using the "LDAP Host" and "LDAP port no" (ldap_connect()) and set the correct connection options (ldap_set_option()), especially LDAP_OPT_PROTOCOL_VERSION and LDAP_OPT_REFERRALS
bind to LDAP server using the "LDAP account to bind" and "LDAP account password" (ldap_bind()) - if you're authenticating against an Active Directory server you can directly use the username and password from the login page and skip all the following steps.
search the tree for a matching user entry/object by specifing the "BASE DN" and the appropriate LDAP filter - most likely something like (&(objectClass=user)(sAMAccountName=%s)) where %s should be replaced by the username to be authenticated (ldap_search())
check if the number of returned entries is 1 (if <> 1 then something has gone wrong, e.g. no user found or multiple users found)
retrive the distinguished name (DN) of this single entry (ldap_get_dn())
use the DN found in the last step to try to bind to the LDAP server with the password given at the authentication page (ldap_bind())
if the bind succeeds then everything is OK, if not, most likely the password is wrong
It's really not as hard as it sounds at first. Generally I'd propose to use some sort of standard library for authenticating against a LDAP server such as the Net_LDAP2 PEAR package or Zend_Ldap out of the Zend Framework. I have no experience with actually using Net_LDAP2 (although I know the code quite well) but Zend_Ldap works very well against Active Directory servers or ADAMS servers (which is obviously what you're working with).
This will do the trick using Zend_Ldap:
$options = array(
'host' => 'ad.blueroom.ac.uk',
'useStartTls' => true,
'accountDomainName' => 'blueroom.ac.uk',
'accountCanonicalForm' => 4,
'baseDn' => 'ou=bluebird,dc=bluebird,dc=ac,dc=my',
);
$ldap = new Zend_Ldap($options);
try {
$ldap->bind('user', 'password');
} catch (Zend_Ldap_Exception $e) {
// something failed - inspect $e
}
// bind successful
$acctname = $ldap->getCanonicalAccountName('user', Zend_Ldap::ACCTNAME_FORM_DN);
You might try http://code.activestate.com/recipes/101525/ while referring to http://us3.php.net/ldap and other results from a Google search for [php ldap authentication].
#Stephen provided good points. Here is my plain PHP code to authenticate using AD:
first you need to know this parameters: server host, user domain (you need also base dn if you want query AD).
use the following code:
$ldap = ldap_connect($host); // e.g. 165.5.54.6 or an URL
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); // Recommended for AD
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($ldap, $username.'#'.$userDomain, $passwrod);
if($bind){
// successful authentication.
}
you could use http://pear.php.net/package/Net_LDAP2/docs
it's nice and works.
Example of connection taken by the doc:
// Inclusion of the Net_LDAP2 package:
require_once 'Net/LDAP.php';
// The configuration array:
$config = array (
'binddn' => 'cn=admin,ou=users,dc=example,dc=org',
'bindpw' => 'password',
'basedn' => 'dc=example,dc=org',
'host' => 'ldap.example.org'
);
// Connecting using the configuration:
$ldap = Net_LDAP2::connect($config);
// Testing for connection error
if (PEAR::isError($ldap)) {
die('Could not connect to LDAP-server: '.$ldap->getMessage());
}