how to specify ldap server address when binding to the ldap server? - python

I am trying ldap authentication. My ldap server is located at x.x.x.x . I am using python-ldap. Connection on server locally doing:
ldap.initialize('ldap://localhost:389')
works fine,
but when i try to connect to the server from another machine, doing:
ldap.initialize('ldap://x.x.x.x:389')
it doesnt work.
What is it that I should do?

This was resolved by way of lifting firewall-based restrictions.

Related

Connecting to Redshift via psycopg2 fails

I have whitelisted ec2 IP address but without 0.0.0.0/0 configuration, I can't connect to the Redshift database from psycopg2. What can be done about this situation where we want to request from a particular IP address.
Is this is the bug that exists when you try to connect it programmatically
Edit:
I tried to whitelist my local IP address and ran my program on the local server and it got connected. But I am not able to connect via my application hosted on EC2 instance.

How to connect to Cloud SQL from pgAdmin4?

I have an instance of PostgreSQL 11 in GCP as Cloud SQL.
I want to connect pgAdmin to the server but I don't know to what port. Where can I see that?
I don't want to specify my ip adress for the server and I whitelisted all the connections to the server by putting 0.0.0.0/0 as an ip in the gcp console.
Multiple methods can be used to connect Cloud SQL to external applications such as pgAdmin. Here is the documentation covering all the methods and the steps to follow. Since you do not wish to specify your ip address, then using the proxy might be a good alternative. Documentation guidelines for that method can be found here, but here is a quick summary:
Enable the API
Install the proxy client on your local machine
Determine how you will authenticate the proxy
If required by your authentication method, create a service account
Determine how you will specify your instances for the proxy
Start the proxy
Update your application to connect to Cloud SQL using the proxy

Django - Host a website on a Lan Network

I've been working on a website for the past month, and now its time for me to host the django website onto a private server. Is there a detailed method on how I'm supposed to host the website onto a specific IP address assigned to my system?
This is my first time dealing with hosting a server and i dont know much about it.
Also, once i host it, How do i change the link from being the IP address to an actual link like "12345678.com" or something like that?
(The website should be hosted in such a way that only the people who are in the same network/lan connection should have access to the website.)
I have wamp on the system and the system has a Windows Server OS (if this info helps)
you can run your codes with manage command like this
python manage.py runserver 0.0.0.0:8000
but its strongly recommended to run your code with a web server like nginx or apache read this tutorial to run your site on a linux server
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04
on windows you can use IIS but its not recommended. its performance is not good
to use 1234567890.com instead of using server ip address you must setup a DNS server on your local network. in linux you can use bind and windows server have its own DNS server. but in your DHCP configuration you must set this DNS server as clients DNS.

Can MySQLdb on client machine connect to a database on a server machine?

I am not a network/web/internet programmer so please excuse my noobness in this area. I have gotten a website using a free hosting service. They include one MySQL database. Here are the details for the database:
port = 3306
host = "fdb4.biz.nf"
database = "1284899_6067"
user = "1284899_6067"
password = "somepass9351"
I am using MySQLdb module (installed on my CLIENT machine - not server) to connect to this database:
db = MySQLdb.connect(host=host, user=user, passwd=password, db=database,port=port)
But I get the following error:
OperationalError: (2003, "Can't connect to MySQL server on 'fdb4.biz.nf' (10060)
What I have already tried
tried two different databases from different hosts
tried changing the port
tried searching SO for similar answers but all others connect to 'local host'
What I think:
could this be caused by my firewall? I am using my school's internet. I don't think this could be it because I am on CLIENT so if anything it is the SERVER'S firewall.
Two questions
Can MySQLdb be used to connect to a db on a SERVER when it is imported on a CLIENT?
If yes, what am I doing wrong?
Thank you so much for any help, its greatly appreciated! Been stuck the whole day on this.
For security reasons, mysql only listens for connections from localhost. Error code 10060 is basically that: you are not allowed to connect remotely.
Solution: find a my.ini (or my.cnf in linux) and try to find a line:
bind-address = 127.0.0.1
this line says: allow only local connections. So, you should comment-out this line, or set your IP address.
Yes, MySQLdb can connect to remote hosts.
And your usage of the connect method is correct.
You should first check if you can connect to the remote mysql server from your mysql client.
In terminal you can type mysql -h hostname -u username -p databasename
This should prompt you for the password. Enter the password. Can you connect?
If you can't connect, then you have an access problem, and its not a python - mysqldb problem
Either the server is not reachable because it is behind a firewall, in that case your client machine's ip needs to be whitelisted. Check your firewall settings
Or, the mysql server running on the remote machine is configured to accept only local connections. I think this is the default, but I'm not sure. You should ssh into the server remote host where the database server is running, locate the my.cnf file on the server and check the settings. Depending on your mysql version, the configuration would look slightly different.
Or, the user that you're trying to connect as is not associated with the ip that you're trying to connect from. Mysql users have two parts, like this: 'username'#'host'. To enable a user to connect from all ips the user needs to look like this 'user'#'%'.
I hope I've given you enough to try to debug this issue.

What do I use for HOST to connect to a remote server with mysqldb python?

Things to note in advance:
I am using wampserver 2.2
Ive forwarded port 80
I added a rule to my firewall to accept traffic through port 3306
I have added "Allow from all" in directory of "A file i forget"
My friend can access my phpmyadmin server through his browser
I am quite the novice, so bear with me.
I am trying to get my friend to be able to alter my databases on my phpmyadmin server through
python. I am able to do so on the host machine using "127.0.0.1" as the HOST. My Question is, does he have to use my external ip as the HOST or my external ip/phpmyadmin/ as the HOST? And if using the external ip iscorrect...What could the problem be?
If your phpmyadmin runs on the same machine as mysql-server, 127.0.0.1 is enough (and safer if your mysql server binds to 127.0.0.1, rather than 0.0.0.0) if you use tcp(rather than unix socket).

Categories

Resources