Hi I am using the code below to retrieve client username on my website but it only works for me on localhost, other people connected remotely to the file its just finding nothing with no errors or anything.
exec("wmic /node:$_SERVER[REMOTE_ADDR] COMPUTERSYSTEM Get UserName", $user);
echo($user[1]);
What is the problem ?
For a remote system you may need to send administrator credentials, e.g.
exec("wmic /node:$_SERVER[REMOTE_ADDR] /user:administrator /password:mypassword COMPUTERSYSTEM Get UserName", $user);
echo($user[1]);
I'd also research if safe to trust REMOTE_ADDR and use it in this way with wmic.
If you are using IIS and looking to get the remote users AD username, this may help: Can you get a Windows (AD) username in PHP?
Related
I'm trying to connect to OpenLDAP using Laravel. All I did was follow the https://ldaprecord.com/docs/laravel/v1/ tutorial. But this tutorial only connect to trial LDAP. I need to connect to my localhost openLDAP.
I'm using these .env configs:
LDAP_LOGGING=true
LDAP_CONNECTION=default
LDAP_HOST=127.0.0.1
LDAP_USERNAME=null
LDAP_PASSWORD=null
LDAP_PORT=10389
LDAP_BASE_DN="dc=example,dc=com"
LDAP_TIMEOUT=5
LDAP_SSL=false
LDAP_TLS=false
Ldap connection test comes successful. But when I try to login using UI, I get that credentials are wrong. i only have created one user so cant be wrong.
From the documentation: "To connect to your LDAP server, a username and password is required to be able to query and run operations on your server(s)."
So you need to enter a (proxy) username and password at the LDAP_USERNAME and LDAP_PASSWORD prompts in order for the application to be able to interact with the LDAP server.
My guess is that you need to enter the user DN and not the short username: uid=username,ou=people,dc=example,dc=com or similar
I tried new connection via:
$conn = new PDO("sqlsrv:server=SERVERNAME;database=DBNAME;MultipleActiveResultSets=false", "username", "password");
and it did not work, however when I remove the username and password it works fine.
username is the same as my windows login, I tried multiple combinations as DOMAIN\username or username#domain.com etc, nothing works. However when username and password are not present, then it connects fine.
The error is:
SQLSTATE[28000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'username'.
so to my question, in order to debug the problem.
Is it possible to check what username is used when automatic authentication is used after the login succeed?
EDIT: so once upon login without username and pass i tried:
Select name FROM DBNAME.sys.syslogins
and it gave me "DOMAIN\USERNAME"
I have tried that several times even before, but still same error :(
EDIT2: is it in db loginlist authorization? I have tried SQL Studio to log in via Windows authentication - works fine, however when i sqich to SQL server authentication and use the correct username and password, it gives me same error again, like the username is not existing anymore...
So at the end, I have found out that one account can not be set to log in via SQL authentication and windows authentication as well. So If I can login via windows authentication (no username and pass entered), then only way is to create new account with same username and set it as SQL Authentication upon Login.
Please correct me if Im wrong (and mainly someone who can test otherwise - because i have found security setting to the account which says "SQL Server and Windows Authentication mode" which is active anyway but doesnt work, and according to our database admin, this setting is not what its for)
I have a mongoDB server using v2.4.9. I need to connect to that server using robomongo in my localhost.
I have enabled auth=true in /etc/mongobd.conf and I have added the username and password in mongodb.php. When I login using robomongo to the remote server, it is connecting already through IP even though I have not prescribed anything in Authentication tab in robomongo. I want robomongo not to connect only through IP, but through both IP and username and password.
How can I do this?
have you created the user with specifications of role and databaseName etc. in robomongo Refer to this link->
https://docs.mongodb.com/manual/reference/method/db.createUser/
I get this error message
Access denied for user 'user'#'localhost' (using password: YES)
I tried to access with the root, the admin account and some user account I made for the web visitors with a few privileges. Those users (admin and web user) were created with cPanel.
I'm testing the connection with this simple code to avoid making a mess with functional code.
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
I stumbled with this explanation but it doesn't work either
Your cPanel username and password can be used to connect to your databases (as well as your cPanel). If you're connecting to your database using your cPanel username and password, you can reset your cPanel password to ensure you are using the correct username and password.
If you setup a MySQL username and password specifically for accessing a database, you'll want to ensure you are using the correct username in your php scripts. For example, MySQL usernames are always in this format:
cpanel-username_mysql-username
If your cPanel username is userna5 and you created a database username of dbuser1, then the actual database username would be:
userna5_dbuser1
Edit: i already assigned the users to a database and their privileges. I'm working on a remote server
I faced the exact same issue on one of my employees' Windows PC.
The issue was caused duo the fact that his private repositories folders including those who were used by Docker were located in C:\Users{user_name} folder.
At some point in time, Windows prevented Docker's access to these folders.
Solution: relocation the folders outside the Users folder solved the issue.
Are you running the code on your local machine or on the remote server. If it's running on your local machine you'll have to replace 'localhost' with the ip address of the server eg. '123.123.123.123'
If you are using the online server after creating the user and the database make sure you give the user privilege to access the database
If you are accessing MySQL database from the remote server, you will have to use server IP address for MySQL host. Also you will have to allow your remote server IP address in "Remote MySQL" under your cPanel otherwise you will not be able to access your database remotely.
I need to open my database through PHP. But I need to know my username and the name of my host (e.g. localhost), and I don't know them.
When I used mysql and did my database, it just asked me directly for a password.
How do I find my host and username on mysql?
type this command
select CURRENT_USER();
You will get the username and server
The default username is root. You can reset the root password if you do not know it: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html. You should not, however, use the root account from PHP, set up a limited permission user to do that: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
If MySql is running on the same computer as your webserver, you can just use "localhost" as the host
Default user for MySQL is "root", and server "localhost".
You should be able to access the local database by using the name localhost. There is also a way to determine the hostname of the computer you're running on, but it doesn't sound like you need that. As for the username, you can either (1) give permissions to the account that PHP runs under to access the database without a password, or (2) store the username and password that you need to connect with (hard-coded or stored in a config file), and pass those as arguments to mysql_connect. See http://php.net/manual/en/function.mysql-connect.php.
This is how you can open MySQL shell
\connect root#localhost:3306