Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Can not login with UPN. #220

Closed
svhsvh opened this issue Oct 8, 2018 · 25 comments
Closed

Can not login with UPN. #220

svhsvh opened this issue Oct 8, 2018 · 25 comments
Assignees
Labels
enhancement Nice to have. help wanted Usually used alongside a bug / enhancement / shouldfix
Milestone

Comments

@svhsvh
Copy link

svhsvh commented Oct 8, 2018

PassCore Server

  • OS: [Windows ]
  • Provider: [Active Directory ]

Describe the bug
Our users are used to login with their UPN, but they are not able to login with their UPN. If they try passcore returns: "Please enter a valid username", like you can see in the image below:

Screenshots
image

I hope someone knows the solution to our problem or is able to help us, thanks in advance.

@diogenes25
Copy link
Contributor

The identity is searched by default over the "cn". If you want to find the identity through the UPN, you can change line 26 in File PasswordChangeProvider.cs as followed.

 public ApiErrorItem PerformPasswordChange(string username, string currentPassword, string newPassword)
        {
            // perform the password change
            try
            {
                using (var principalContext = AcquirePrincipalContext())
                {
                   // ########## Replace this line ... ##################
                   //  var userPrincipal = UserPrincipal.FindByIdentity(principalContext, username);
                   //  ####### with this line !!! Set ItenditityType to: IdentityType.UserPrincipalName #####
                    var userPrincipal = UserPrincipal.FindByIdentity(principalContext, IdentityType.UserPrincipalName, username);

            .....

@svhsvh
Copy link
Author

svhsvh commented Oct 8, 2018

Thanks, where is that file located? because I'm unable to locate it.

@diogenes25
Copy link
Contributor

@svhsvh
Copy link
Author

svhsvh commented Oct 8, 2018

But that is the source code right? Because that file is not present on my passcore installation.

@diogenes25
Copy link
Contributor

Yes it is.
You must change it the "hard way" (with compile and all the stuff)
We had a similar Problem here #204.
Maybe we should put a switch in appsettings.json that defines how a user is found (Distinguished Name (DN), Globally Unique Identifier (GUID), Security Account Manager (SAM), Security Identifier (SID) or User Principal Name (UPN)).

@geoperez
Copy link
Member

geoperez commented Oct 8, 2018

I like your idea.

@svhsvh
Copy link
Author

svhsvh commented Oct 8, 2018

Thanks for your answer. Yes that would be nice!

@geoperez
Copy link
Member

geoperez commented Oct 9, 2018

@svhsvh you can download the current master code or wait for the release probably by Friday.

@geoperez geoperez added enhancement Nice to have. help wanted Usually used alongside a bug / enhancement / shouldfix labels Oct 9, 2018
@geoperez geoperez added this to the 3.5.0 milestone Oct 9, 2018
@svhsvh
Copy link
Author

svhsvh commented Oct 10, 2018

Thanks! I will wait until the release.

@svhsvh
Copy link
Author

svhsvh commented Oct 17, 2018

Just a quick question, where can I find it when this will be released?

@geoperez
Copy link
Member

Sorry guys, I've been busy but probably today I'll release it.

@geoperez geoperez self-assigned this Oct 17, 2018
@geoperez
Copy link
Member

@svhsvh I created a published version from my current branch. Including:

  • The PR to define DC Attrbibute by @diogenes25
  • New appsettings format
  • Logging improved.

PassCore35.zip

Let me know if it's working for you. I'll wait feedback before to publish a release.

@MAP74
Copy link

MAP74 commented Oct 26, 2018

This version works with UPN.
But it fails when user has to change password at next logon.
Error message: You are not allowed to change your password. Please contact your system administrator.

The only version if found where this works ouf of the box is v3.1

@geoperez
Copy link
Member

Are you sure about that? Because the Change Password Provider from 3.1 is pretty much the same code as this version. The only important change is the ability to change the DC attribute to search the user.

There are no changes in how the password is changed.

@svhsvh
Copy link
Author

svhsvh commented Oct 26, 2018

@svhsvh I created a published version from my current branch. Including:

  • The PR to define DC Attrbibute by @diogenes25
  • New appsettings format
  • Logging improved.

PassCore35.zip

Let me know if it's working for you. I'll wait feedback before to publish a release.

Thanks, I will test it out and I will let it know you soon.

@svhsvh
Copy link
Author

svhsvh commented Oct 29, 2018

I'am not able to get PassCore35 working, I get the HTTP Error 502.5. I do not understand why because the stable release is working perfect and on the same server. And I have .NET Core 2.1.1 Windows Server Hosting bundle installed.
screen shot 2018-10-29 at 10 07 02

@geoperez
Copy link
Member

Do you have a log file?

@svhsvh
Copy link
Author

svhsvh commented Oct 30, 2018

Unfortunately not. If I unpack a fresh copy of PassCore34 (stable release) and point the Physical Path in IIS to that directory it works. If I unpack a fresh copy of PassCore35.zip that you posted here and point the Physical Path in IIS to that directory it returns me the 502.5 error.
I assume that PassCore35 has the same dependancies as PassCore34, unless that isn't true I have no idea what I am doing wrong.
Do you have any idea what is wrong? Or could it be a fault in PassCore35?
Thanks in advance.

@MAP74
Copy link

MAP74 commented Oct 30, 2018

Are you sure about that? Because the Change Password Provider from 3.1 is pretty much the same code as this version. The only important change is the ability to change the DC attribute to search the user.

There are no changes in how the password is changed.

Hi,

I did some test to be really sure.

Results below.

Thread that triggered me to try 3.1: #216

Test setup:

AD functional level: 2016
Passcore runs on:
OS: Windows Server 2016 (Member)
Provider: Active Directory
IIS: v10

Password-Policy:

Complexity: Enabled
History: Enabled
Max-Age: Enabled
Min-Age: Enabled
Min-Length: Enabled

Test-User:

Default domain user with "User must change password at next logon" enabled.

######################
Passcore versions tested:
######################

3.1.0

App-Pool IDs:	ApplicationPoolIdentity, Custom AppPool User with AD rights granted, NetworkService
Message-WebIf:	You have changed your password successfully.
		Please note it may take a few hours for your new password to reach all domain controllers.
Message-Logfi:	no usable error messages found
				(Loglevel:Debug)

3.2.0 (Upgrade to new ASP.NET Core 2.1)

App-Pool IDs:	ApplicationPoolIdentity, Custom AppPool User with AD rights granted, NetworkService
Message-WebIf:	You have changed your password successfully.
		Please note it may take a few hours for your new password to reach all domain controllers.
Message-Logfi:	no usable error messages found
				(Loglevel:Debug)

3.3.0

App-Pool IDs:	ApplicationPoolIdentity, Custom AppPool User with AD rights granted, NetworkService
Message-WebIf:	Access is denied.
Message-Logfi:	no usable error messages found
				(Loglevel:Debug)

3.4.2

App-Pool IDs:	ApplicationPoolIdentity, Custom AppPool User with AD rights granted, NetworkService
Message-WebIf:	Access is denied.
Message-Logfi:	no usable error messages found
				(Loglevel:Debug)

3.5.0

App-Pool IDs:	ApplicationPoolIdentity, Custom AppPool User with AD rights granted, NetworkService
Message-WebIf:	Failed to update password: Access is denied.
Message-Logfi:	info: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  PerformPasswordChange for user mpxxx@xyz.com
		info: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  PerformPasswordChange for user mpxxx@xyz.com
		warn: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  Using AutomaticContext
		warn: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  Using AutomaticContext	
		warn: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  The User principal password have no last password
		warn: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  The User principal password have no last password
				(Loglevel:Debug)

Changed default settings in all versions for this test:

appsettings.json
#########################################
"Logging": {
	"LogLevel": {
		"Default":   "Debug",
		"System":    "Debug",
		"Microsoft": "Debug" }
}

"AppSettings": {"DefaultDomain": "FQDN of our AD domain"}
	and
"AppSettings": {"DefaultDomain": ""}

web.config
#########################################
stdoutLogEnabled="true"

Current setup running without problems:

Right now I'm on v3.2 with AppPoolID "Network Service".

@geoperez
Copy link
Member

geoperez commented Oct 30, 2018

@svhsvh Passcore350 has a different setting file, did you check that?

@geoperez
Copy link
Member

@MAP74 wow! thank you for the information. Let me review again the changes between 320 and 330.

@diogenes25
Copy link
Contributor

Are you sure about that? Because the Change Password Provider from 3.1 is pretty much the same code as this version. The only important change is the ability to change the DC attribute to search the user.

One little (maybe important) change is, that the UPN will be used to check the old password.

if (ValidateUserCredentials(userPrincipal.UserPrincipalName, currentPassword, principalContext) == false)

Maybe the UPN is not set in the DC?
Just an idea.

@geoperez
Copy link
Member

geoperez commented Oct 30, 2018

I noticed a changed introduced after 3.2.0 to set the last password property, and I guess it may could affect. The following release includes a new setting named UpdateLastPassword (default value false). If the value is true will execute the last password check, otherwise, continue to password changing.

PassCore35.zip

For more information about the Last Password check, see issue #21.

@MAP74
Copy link

MAP74 commented Oct 31, 2018

@geoperez The new 3.5 you provided does the trick. Changing passwords with option "User must change password at next logon" enabled is working again,

Log

Message-Logfi:	info: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  PerformPasswordChange for user mpx@xyz.com
		info: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  PerformPasswordChange for user mpx@xyz.com
		warn: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  Using AutomaticContext
		warn: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  Using AutomaticContext
		dbug: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  The User principal password updated with setPassword
		dbug: Unosquare.PassCore.PasswordProvider.PasswordChangeProvider[0]
			  The User principal password updated with setPassword

Thank you.

Question

The PasswordMeter seems to use the classic complexity requirements to measure if your password is a strong one.

Passw0rd%
is considered a lot stronger than
this is an absolute insane long password if you have to type it in every time but easy to remember
Ironically it provides a link to https://xkpasswd.net/s/ where we are teached why classic passwords are unsafe and why long and easy to remember passwords with a high entropy should be preferred.

Is this something where the password meter can be improved?

@geoperez
Copy link
Member

That's cool! Regarding the PasswordMeter, you are right, the current implementation is not right. But I'll target that issue in the following version. I want to release 3.5.0 now to fix the issues between 3.2.0 and 3.4.0.

Can you submit this like a new issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Nice to have. help wanted Usually used alongside a bug / enhancement / shouldfix
Projects
None yet
Development

No branches or pull requests

4 participants