How to connect to ldap in dart/flutter? - flutter

Hello,
I tried to connect my flutter app with my company's active directory but it didn't work. I need one thing, just to know is credentials are correct and connection can be established, nothing more.
I found dartdap and other problem on stackoverflow but it doesn't help.
My code is:
var host = '10.1.1.5';
var login = 'myLogin'; //loginController.text;
var password = 'myPassword'; //passController.text;
var port = 389;
var connection = new LdapConnection(host: host, ssl: false, port: port, bindDN: login, password: password);
try {
await connection.open();
await connection.bind();
print('Bind OK');
} catch (e, stacktrace) {
print('********* Exception: $e, Stacktrace: $stacktrace');
} finally {
print('Closing');
await connection.close();
}
}
And I tried with this config:
var host = '10.1.1.5';
var login = 'mylogin'; //
var base = 'DC=I,DC=domain,DC=com';
var bindDN = "cn=" + login + "," + base;
var password = 'mypassword'; //passController.text;
var port = 389;
And when I want to connect, I got response with Invalid Credentials in both situations.
I/flutter (10334): ********* Exception: Invalid credentials80090308: LdapErr: DSID-0C09044E, comment: AcceptSecurityContext error, data 52e, v2580
That credentials are 100% correct, but data 52e means: Returns when username is valid but password/credential is invalid. (from ldapwiki).
I haven't got any ideas, please help mates :(

Are you sure that port 389 is open on firewall?

Related

Connecting to Heroku Postgres from Auth0 results in: err no pg_hba.conf entry for host, no encryption

I'm trying to connect to my PostgreSQL database hosted on Heroku through Auth0's Database Connections.
I am getting an error when I try to invoke the Get User script within Auth0's database actions:
no pg_hba.conf entry for host "xx.xxx.xx.x", user "xxx", database "xxx", no encryption
The script looks like this:
function loginByEmail(email, callback) {
const postgres = require('pg');
const conString = configuration.DATABASE_URL;
postgres.connect(conString, function (err, client, done) {
if (err) return callback(err);
const query = 'SELECT id, nickname, email FROM organizations WHERE email = $1';
client.query(query, [email], function (err, result) {
done(); // Close the connection to the database
if (err || result.rows.length === 0) return callback(err);
const user = result.rows[0];
return callback(null, {
user_id: user.id,
nickname: user.nickname,
email: user.email
});
});
});
}
Connection String:
configuration.DATABASE_URL: 'postgres://xxx:xxx#xxx?sslmode=require'
I appended sslmode=require to the end of my connection string to ensure I have a SSL connection to my database.
I have also tried changing sslmode=require to ssl=true, which results in a different error:
self signed certificate
I am unsure where to go from here, so any help would be appreciated.
You should first establish the client and specify the rejectUnauthorized flag, like so:
const client = new postgres.Client({
connectionString: conString,
ssl: { sslmode: 'require', rejectUnauthorized: false }
});
Then, instead of using your postgres to connect, use the client:
client.connect();
client.query(...);
This should solve your problem, and the connection will be encrypted. You won't, however, be protected against Man-In-The-Middle (MITM) attacks, as specified in documentation.
#Pexers solution worked for me, however, somehow it shows TypeScript error. The way I did it is just ssl: true:
const client = new postgres.Client({
connectionString: conString,
ssl: true
});

Pipedream's MongoDB API connection not working?

https://www.pipedream.com has an UI-assisted integration with MongoDB. It requires 4 values to connect to the API:
$username
$password
$database
$hostname
my default connect to app connection string is: mongodb+srv://<username>:<password>#cluster0.45xcf.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
(yes, I'm using the default cluster0 and myFirstDatabase values here)
I get back this error response:
MongoAPIError
URI must include hostname, domain name, and tld
DETAILS
at null.resolveSRVRecord (/tmp/ee/c_m4fDxGe5/node_modules/.pnpm/mongodb#4.5.0/node_modules/mongodb/lib/connection_string.js:51:25)
at null.connect (/tmp/ee/c_m4fDxGe5/node_modules/.pnpm/mongodb#4.5.0/node_modules/mongodb/lib/operations/connect.js:32:57)
at null.null (/tmp/ee/c_m4fDxGe5/node_modules/.pnpm/mongodb#4.5.0/node_modules/mongodb/lib/mongo_client.js:127:35)
at null.maybePromise (/tmp/ee/c_m4fDxGe5/node_modules/.pnpm/mongodb#4.5.0/node_modules/mongodb/lib/utils.js:409:5)
at MongoClient.connect (/tmp/ee/c_m4fDxGe5/node_modules/.pnpm/mongodb#4.5.0/node_modules/mongodb/lib/mongo_client.js:126:41)
at Function.connect (/tmp/ee/c_m4fDxGe5/node_modules/.pnpm/mongodb#4.5.0/node_modules/mongodb/lib/mongo_client.js:190:36)
at Object.run (/steps/mongodb.js:19:38)
at global.executeComponent (/var/task/launch_worker.js:171:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:653:28)
I'm trying to connect to the API with:
$username = {REDACTED}
$password = {REDACTED}
$database = myFirstDatabase
$hostname = cluster0
and it's not able to connect, but it does work connecting via mongosh, Compass, etc
here's the full Node.js code Pipedream uses to connect to MongoDB's API:
module.exports = defineComponent({
props: {
mongodb: {
type: "app",
app: "mongodb",
}
},
async run({steps, $}) {
const MongoClient = require('mongodb').MongoClient
const {
database,
hostname,
username,
password,
} = this.mongodb.$auth
const url = `mongodb+srv://${username}:${password}#${hostname}/test?retryWrites=true&w=majority`
const client = await MongoClient.connect(url, {
useNewUrlParser: true,
useUnifiedTopology: true
})
const db = client.db(database)
// Enter your target collection as a parameter to this step
this.res = await db.collection(params.collection).insertOne({ name: "Luke Skywalker" })
await client.close()
},
})
Just don't understand why it won't connect. I can confirm the username and password aren't the problem.
I had a similar error message and it was a red herring.
The hostname needed to be the whole thing; cluster0.xx0xx.mongodb.net in my case, and I had the password wrong.

ConnectionError: Connection lost - read ECONNRESET in protractor

I am using protractor 52.2 and cucumber 3.2.2. I am using selenium grid(selenium-server-standalone-3.14.0.jar) with the protractor and running my script in 4 browsers of 4 different nodes. I have a table of 600 rows in the DB. Initially, I am accessing data from this table and entering the data of each row through my protractor script and updating the DB column after successful entering of each row. But after entering some rows successfully, protractor script abruptly ends with error "ConnectionError: Connection lost - read ECONNRESET in protractor".And I am getting an error message in update SQL query, that "RequestError: Resource ID: 1. The request limit for the database is 60 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' for assistance." The update query which I am using is given below(i am using azure sql). I am not getting a clear idea of how to solve this. Thanks in advance.
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var config =
{
userName: 'xxx',
password: 'xxxxx',
server: 'xxxxxx',
options:
{
database: 'xxx' ,
encrypt: true,
rowCollectionOnRequestCompletion: true
}
}
var connection = new Connection(config);
defineSupportCode(function ({ setDefaultTimeout, Given, When, Then }) {
setDefaultTimeout(30000 * 1000);
function updatedb(LPAID){
request = new Request("UPDATE COM_Location_Post with (rowlock) SET IsPublished = 1 WHERE Id ="+LPAID,function(err,rowCount, rows) {
if(err){
console.log(err)
}
});
connection.execSql(request);
}
});
You did not use connection close in your script.
By your question its clear after max instance you face this problem.
Try closing your connection every time for each transaction.
(async () => {
const config = {
user: 'User',
password: 'iPg$',
server: 'cp-sql',
database: 'DBI',
options: {
encrypt: true // Use this if you're on Windows Azure
}
}
try {
let pool = await sql.connect(config)
var envcode, testcode;
let result1 = await pool.request()
.query(`query 1 goes here`)
// console.dir(result1)
pool.close();
sql.close();
let pool1 = await sql.connect(config)
let result2 = await pool1.request()
.query(`query 2 goes here`)
// console.dir(result2)
pool1.close();
sql.close();
resolve(result2);
} catch (err) {
console.log(err)
}
})()

React Native Parse LiveQuery error on socket

I am having trouble connecting to the LiveQuery server that I setup on the server side of my React Native project. I followed the instructions on the site verbatim, but can only manage to get 'error on socket' when I connect with numerous attempts by the server to reconnect.
Here is my server setup:
liveQuery: {
classNames: ['BekonRequest'],
}
var port = 1337;
server.listen(port, function() {
console.log('parse-server running on port ' + port); });
var parseLiveQueryServer = ParseServer.createLiveQueryServer(server);
server.listen(port, function() {
console.log('parse-server running on port ' + port);
});
var parseLiveQueryServer = ParseServer.createLiveQueryServer(server);
And my client side code:
let requestQuery = new Parse.Query('BekonRequest');
requestQuery.equalTo("username", "broncos#nfl.com");
let subscription = requestQuery.subscribe();
subscription.on('create', (requests) => {
console.log(requests);
});
Can anyone see why I am not able to connect successfully?

Net Module Nodester not Listening to Port

I have a basic node.js app that is designed to open up a connection between two clients and echo the input of one to the other.
var net = require("net");
console.log("Relay Started");
var id = 0;
var Socket = [];
relay = net.createServer(function(socket) {
socket.on('connect', function() {
console.log('Connected');
if(socket.id==null) {
socket.id = id;
Socket[id]=socket;
id++;
}
});
socket.on('data', function(data) {
data = data.toString()
if (socket.id==0) {
Socket[1].write(data);
} else if (socket.id==1) {
Socket[0].write(data);
}
console.log(socket);
console.log(data.toString());
});
})
relay.listen(process.env['app_port']||8080);
It works fine when run locally, however when I put it onto a Nodester development server, I am unable to connect by using telnet zapcs.nodester.com 18007 (it is hosted under the name zapcs, and the given port is 18007). The Relay Started is logged, but nothing after that, and no connection. Any ideas on why this would be?
~
you can not telnet zapcs.nodester.com 18007, you only can connect to zapcs.nodester.com:80 by http or websock, nodester will route your request to your app actual port (18007) on the host.
And check this: http://www.slideshare.net/cmatthieu/nodester-architecture-overview-roadmap-9382423