Bug 5277 - "Your password has expired and must be changed." - But it cannot.
Summary: "Your password has expired and must be changed." - But it cannot.
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: x64 Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Andrew Bartlett
Depends on:
Reported: 2008-02-24 14:31 UTC by Andrew Kroeger
Modified: 2008-05-22 05:32 UTC (History)
1 user (show)

See Also:

Debug output during the initial login attempt (4.03 KB, text/plain)
2008-02-24 14:33 UTC, Andrew Kroeger
no flags Details
Debug output while attempting to change password (15.71 KB, text/plain)
2008-02-24 14:34 UTC, Andrew Kroeger
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Kroeger 2008-02-24 14:31:44 UTC
Working with a S4 installation that was initially provisioned on 12-Jan-2008.

When attempting to log in today, received the "Your password has expired and must be changed." message from Windows.  The password change dialog was displayed, but upon attempting the change, Windows displayed the error "The system cannot change your password because the domain SMB4 is not available."

Will attach debug logs.
Comment 1 Andrew Kroeger 2008-02-24 14:33:19 UTC
Created attachment 3146 [details]
Debug output during the initial login attempt
Comment 2 Andrew Kroeger 2008-02-24 14:34:38 UTC
Created attachment 3147 [details]
Debug output while attempting to change password
Comment 3 Andrew Bartlett 2008-02-24 19:05:20 UTC
So, we refuse to give a kerberos ticket, because the password has expired.

I think what we need to do is match Microsoft's KDC error return behavior, so we return the NTSTATUS code, which it will then use internally.  

We need to figure out how this works on windows - it might use that error return to try a different password change codepath.

Comment 4 Andrew Kroeger 2008-02-26 00:54:08 UTC
Looking into this a little more, I see "Kerberos: Server's key has expired at -- 2008-02-24T07:18:50" in the debug output from the initial login attempt (first attachment).  It seems that this isn't an issue of user password expiration, but expiration of a kerberos principal (a "machine account" if I understand things correctly).

I have looked at the code and see how the pwdLastSet and maxPwdAge attributes are used to set the pw_end in hdb-ldb.c, which ultimately causes the "Server's key has expired..." message.

If I do understand things correctly, and the message was caused by a machine account expiring, I don't think that machine accounts should expire.  Windows clients that are domain members by default change their machine account passwords on a regular basis, but that can be disabled.  It appears that either S4 doesn't handle machine account password changes, or if it does it is not updating the pwdLastSet attribute when it does.  Additionally, it appears that the pwdLastSet attribute for the S4 DC itself hadn't been updated since the provisioning, which would cause it to expire as well.
Comment 5 Andrew Bartlett 2008-02-26 02:18:24 UTC
Yep, I was coming to a very similar conclusion, when I booted my Win2000 instance (which is similarly old).

I'll arrange machine accounts not to expire for the timebeing. 
Comment 6 Andrew Bartlett 2008-02-27 17:43:58 UTC
Current GIT should not expire machine accounts any more.  

Can you try it out?
Comment 7 Andrew Kroeger 2008-02-27 21:31:01 UTC
Still having problems with current Git.

Manually changed maxPwdAge to 12 hours to test (on my domain that was provisioned over 12 hours prior).

Still get the "Server's key expired..." message during the initial login attempt.

During the password change attempt, instead of:

sam_account_ok: Account for user 'xp-pro$@SMB4.INTERNAL.ID10TS.NET' password expired!.
sam_account_ok: Password expired at 'Sun Feb 24 07:18:50 2008 CST' unix time.

I receive:

logon_hours_ok: No hours restrictions for user xp-pro$@SMB4.INTERNAL.ID10TS.NET
Kerberos: Client's key has expired at 2008-02-26T11:25:43 -- xp-pro$@SMB4.INTERNAL.ID10TS.NET
Comment 8 Andrew Kroeger 2008-02-28 20:53:05 UTC
Closer with the changes made today, but not quite there.

Manually changed maxPwdAge to 10 minutes.

Machine accounts no longer expire.

User accounts that are not supposed to expire (Administrator by default, and any user created with "Password never expires") do not expire.

However, when trying to login with a user whose password has expired or a user created with "User must change password at next logon" checked, Windows displays the message "Unable to log you on because of an account restriction."  There is no opportunity to change/update the password.  The login process is simply denied.

The smbd logs indicate:

"sam_account_ok: Account for user 'test_account_2@SMB4.INTERNAL.ID10TS.NET' password expired!."


"sam_account_ok: Account for user 'test_account_3@SMB4.INTERNAL.ID10TS.NET' password must change!."

It appears there was a change in behavior as part of today's change that is passing different flags back to Windows, causing the "account restriction" message.
Comment 9 Andrew Kroeger 2008-03-07 06:27:10 UTC
I have pushed patches to git://git.id10ts.net/samba.git that fix all but one issue related to the logon process.

The patches send the proper responses to allow the client to process user password changes when the user's password has expired or they are forced to change at next logon.

The flags passed back to the client allow the client to determine (at a coarse level) whether a password needs to be changed or an account is locked/otherwise restricted.  The only remaining issue is to send the NTSTATUS error code back to the client to allow it to display the appropriate message in the user dialog.
Comment 10 Andrew Kroeger 2008-03-07 06:28:56 UTC
Sorry for missing this in my previous reply.

The patches are in the v4-0-logon branch on git://git.id10ts.net/samba.git.
Comment 11 Andrew Bartlett 2008-03-07 06:36:07 UTC
patches have been applied.
Comment 12 Matthias Dieter Wallnöfer 2008-04-22 16:15:36 UTC
This bug seems to be fixed. Please close it!
Comment 13 Matthias Dieter Wallnöfer 2008-05-22 05:32:54 UTC