How to restrict user for SQL Login only with New Password after changing password - sql

I am developing a WPF application with SQL Server 2014.
In our server side, I have created SQL Login as
CREATE LOGIN <username> WITH PASSWORD = <oldPassword> MUST_CHANGE,CHECK_EXPIRATION=ON,CHECK_POLICY=ON, DEFAULT_DATABASE =<databaseName> DEFAULT_LANGUAGE=[English]
Now after changing the password of above user by
ALTER LOGIN <username> WITH PASSWORD = <newPassword> , OLD_PASSWORD =<oldPassword> , DEFAULT_DATABASE=<databaseName>, DEFAULT_LANGUAGE=[English]
I am able to open this connection with Old Password and new password both (by using VS2013 C# connection string ). Condition : It will work only till we restart our server or service.
As per the requirement, user should be able to login only with new password. Can this community help me.
Do we have some restriction in SQL to open connection/login only with New Password.
Thanks in Advance.

Try adding this to your command when changing the password.
OLD_PASSWORD = 'oldpassword'
I think you might just be adding another password rather than replacing it with your current command.

Related

forgot the moodle admin password of my local moodle server

forgot the moodle admin password of my local moodleyour text server
i am using the version 4.1 moodle
i know the username but unfortunetly forgot the password my local moodle server.
i have tried to forgot the password i havent give the smtp address so i cant recieve the mail of reset password
enter image description here
login to moodle server but
i have forgot the passwqord so i am not able to login
You can reset the password from the command line
php admin/cli/reset_password.php --username=admin --password=newpassword
Here is a more hacky approach that works provided you have access to the database.
For context, Moodle uses the PHP function password_hash() to generate a password hash for users. The basic idea is that you want to use this function in a plain PHP file outside of Moodle to output a password hash of a new password. This hash is then manually saved in the password field in your mdl_user table using your database client and your new password used to login to the site.
PHP File:
<?php
echo password_hash("new_password", PASSWORD_DEFAULT);
Example output of password_hash:
$2y$10$NCC4PVZ1kTRg4bT21yEl2eUVWMf3lkbYtczTn8vB53qNwTqtN9jwS

Windows Authentication to Native SQL Authentication

I will ask this question, please correct me if i failed to explained it in a right manners.
What i Have --
"WINDOWS" login Authentication to SQL Server 2012
What i Need --
Create a Native SQL Authentication with a User Name and Password
How i can create a SQL Authentication with a User Name and Password !
Any body knows any solution to this problem !
SQL server has two types of authentication..
1.Windows
2.SQLserver Authentication and windows Auth(mixed)
You can change the authentication to one desired by right clicking on server and clicking on properties as shown in screenshot below..
There are also caveats if only SA account has SYSAdmin permissions..Below is what msdn describes about it..
If Windows Authentication mode is selected during installation, the sa login is disabled and a password is assigned by setup. If you later change authentication mode to SQL Server and Windows Authentication mode, the sa login remains disabled.
To use the sa login, use the ALTER LOGIN statement to enable the sa login and assign a new password. The sa login can only connect to the server by using SQL Server Authentication.
ALTER LOGIN sa ENABLE ;
GO
ALTER LOGIN sa WITH PASSWORD = '<enterStrongPasswordHere>' ;
GO
Now you can create SQLServer based logins like below..
CREATE LOGIN test
WITH PASSWORD = 'somepwd'
You also can change authentication using TSQL..
EXEC xp_instance_regwrite
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode',
REG_DWORD,
2; --Both windows and SQL
References:
How to change SQL Server authorization mode without Management Studio
https://msdn.microsoft.com/en-IN/library/ms188670.aspx

Export pasword ldap (openldap) on liferay not working

I have configured liferay to authenticated to OpenLdap. Cas, import and export is activated.
User create from OpenLdap can authenticate to portal, also is imported into Liferay. It seems importing process is ok.
When user try to modify an attribute other than password the data is modified on OpenLdap.
The problem is when user try to modify their password. Liferay ask for current pass and the new one. It get a error saying credentials an incorrect.
If i try to modify the password of the user with a administrator user, Liferay only ask for the new password. After that, the user with de password changed by de admin user can log in with the new password. So, it seems password is modified correctly on OpenLdap. If user, try to modify again the password, Liferay say that everything was ok, but the user cannot autenticate with the new passord, only with old password.
After that if I try to change de password again with admin user, Liferay say that everthing was ok but the user now cannot authenticate with new password.
I'm using Liferay 6.2 ce.
I have modified :
ldap.auth.method=password-compare
ldap.auth.password.encryption.algorithm=SHA
ldap.auth.method=bind
on portal-setup-wizard.propertiesenter code here
Any Idea?
Thanks very much in advance.
with several values without success.
Compare is not a best practice for LDAP in general.
"Bind is preferred by most vendors so that you don't have to worry about encryption strategies."
Also there appears to be a bug in LifeRay that may affect your version.

change username and password of sql server 2008 default instance

I'm not able to use sql server authentication on the default instance.I have seen a lot of web pages and tried adding a new logins by right clicking on logins in security.Secondly changed the password of sa user but i have observed that in status the "SQl Server login is locked out".I have tried all this with admin rights and still not able to login.

users and logins in sql server 2005 express

I created a login named mylogin with password= 'pass_1'
Then i logged into sql server using this login & tried to create a database , which gave the error that permission denied.
Then i executed this : sp_addsrvrolemember 'mylogin', 'dbcreator'
Then, again I logged into sql server using above login & tried to create a database, this time the database was created successfully
This was because I added the dbcreator server role for the login.
But, then i created a USER myloginuser for LOGIN mylogin ,
then executed this query:
execute as user = 'myloginuser'
then again i tried to create a database, but it failed. why so?
when the login MYLOGIN to which the user MYLOGINUSER is associated has the permission to create a database then why does the user does not have the permission? then whats the solution for this? do i have to grant permission to the user separately irrespective of the permissions granted to the login?
also, a user which is created for a login , have to be created inside a database? is it necessary?
The default user for the LOGIN [mylogin] was mylogin (which was created executing
sp_addsrvrolemember 'mylogin',
'dbcreator'
Hence this mylogin user had the db create permission. But you have created a MYLOGINUSER for the same Login. So the existing user mylogin was set to orphaned user, hence the mylogin Login dropped the db creator permission.
Is the SQL Server Authenticationmode set to Mixed instead of Windows?
Ypu'll have to set it to mixed.
A user must be created at the SQL Server level and given permissions in (mapped to) a database.