Return infinite time for last last logoff when last logoff = 0
authorMatthieu Patou <mat@matws.net>
Sat, 1 Aug 2009 10:02:58 +0000 (14:02 +0400)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 3 Aug 2009 04:08:15 +0000 (14:08 +1000)
source4/auth/auth_sam_reply.c
source4/auth/sam.c
source4/dsdb/common/util.c

index dfa76234b4b631c1a09f2a9c1736ee624fad2647..88eb857eb3ac29dac08ef5b46d5bfe209386507e 100644 (file)
@@ -38,7 +38,7 @@ NTSTATUS auth_convert_server_info_sambaseinfo(TALLOC_CTX *mem_ctx,
        sam->domain_sid->num_auths--;
 
        sam->last_logon = server_info->last_logon;
-       sam->last_logoff = server_info->last_logoff;
+       sam->last_logoff =  server_info->last_logoff;
        sam->acct_expiry = server_info->acct_expiry;
        sam->last_password_change = server_info->last_password_change;
        sam->allow_password_change = server_info->allow_password_change;
index 6285c31e5cee79a2a9968cbb49a6e7af623c3b46..c8591b392755dd1154ec1efd7fb7db4074668a06 100644 (file)
@@ -442,7 +442,7 @@ _PUBLIC_ NTSTATUS authsam_make_server_info(TALLOC_CTX *mem_ctx,
        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(server_info->logon_server, tmp_ctx);
 
        server_info->last_logon = samdb_result_nttime(msg, "lastLogon", 0);
-       server_info->last_logoff = samdb_result_nttime(msg, "lastLogoff", 0);
+       server_info->last_logoff = samdb_result_last_logoff(msg);
        server_info->acct_expiry = samdb_result_account_expires(msg);
        server_info->last_password_change = samdb_result_nttime(msg, "pwdLastSet", 0);
 
index 247aec703592bc6317ba9f60165fad2d12af21aa..5c5386b64c9cafdb5ca126562cf9b054dbec6488 100644 (file)
@@ -435,6 +435,22 @@ NTTIME samdb_result_nttime(struct ldb_message *msg, const char *attr, NTTIME def
        return ldb_msg_find_attr_as_uint64(msg, attr, default_value);
 }
 
+/*
+ * Windows stores 0 for lastLogoff.
+ * But when a MS DC return the lastLogoff (as Logoff Time)
+ * it returns 0x7FFFFFFFFFFFFFFF, not returning this value in this case
+ * cause windows 2008 and newer version to fail for SMB requests
+ */
+NTTIME samdb_result_last_logoff(struct ldb_message *msg)
+{
+       NTTIME ret = ldb_msg_find_attr_as_uint64(msg, "lastLogoff",0);
+
+       if (ret == 0)
+               ret = 0x7FFFFFFFFFFFFFFFULL;
+
+       return ret;
+}
+
 /*
  * Windows uses both 0 and 9223372036854775807 (0x7FFFFFFFFFFFFFFFULL) to
  * indicate an account doesn't expire.