[SAMSRV]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 6 Oct 2013 23:09:46 +0000 (23:09 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 6 Oct 2013 23:09:46 +0000 (23:09 +0000)
A password is present only if the passwords value has been set and the password is not the empty password.

svn path=/trunk/; revision=60567

reactos/dll/win32/samsrv/samrpc.c

index 2282fde..0538f60 100644 (file)
@@ -6305,6 +6305,9 @@ SampQueryUserInternal1(PSAM_DB_OBJECT UserObject,
     if (InfoBuffer == NULL)
         return STATUS_INSUFFICIENT_RESOURCES;
 
+    InfoBuffer->Internal1.LmPasswordPresent = FALSE;
+    InfoBuffer->Internal1.NtPasswordPresent = FALSE;
+
     /* Get the NT password */
     Length = 0;
     SampGetObjectAttribute(UserObject,
@@ -6322,9 +6325,13 @@ SampQueryUserInternal1(PSAM_DB_OBJECT UserObject,
                                         &Length);
         if (!NT_SUCCESS(Status))
             goto done;
+
+        if (memcmp(&InfoBuffer->Internal1.EncryptedNtOwfPassword,
+                   &EmptyNtHash,
+                   sizeof(ENCRYPTED_NT_OWF_PASSWORD)))
+            InfoBuffer->Internal1.NtPasswordPresent = TRUE;
     }
 
-    InfoBuffer->Internal1.NtPasswordPresent = (Length == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
 
     /* Get the LM password */
     Length = 0;
@@ -6343,9 +6350,12 @@ SampQueryUserInternal1(PSAM_DB_OBJECT UserObject,
                                         &Length);
         if (!NT_SUCCESS(Status))
             goto done;
-    }
 
-    InfoBuffer->Internal1.LmPasswordPresent = (Length == sizeof(ENCRYPTED_LM_OWF_PASSWORD));
+        if (memcmp(&InfoBuffer->Internal1.EncryptedLmOwfPassword,
+                   &EmptyLmHash,
+                   sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
+            InfoBuffer->Internal1.LmPasswordPresent = TRUE;
+    }
 
     InfoBuffer->Internal1.PasswordExpired = FALSE;
 
@@ -6709,6 +6719,9 @@ SampQueryUserAll(PSAM_DB_OBJECT UserObject,
     /* Get the LmPassword and NtPassword attributes */
     if (InfoBuffer->All.WhichFields & (USER_ALL_NTPASSWORDPRESENT | USER_ALL_LMPASSWORDPRESENT))
     {
+        InfoBuffer->All.LmPasswordPresent = FALSE;
+        InfoBuffer->All.NtPasswordPresent = FALSE;
+
         /* Get the NT password */
         Length = 0;
         SampGetObjectAttribute(UserObject,
@@ -6717,8 +6730,6 @@ SampQueryUserAll(PSAM_DB_OBJECT UserObject,
                                NULL,
                                &Length);
 
-        InfoBuffer->All.NtPasswordPresent = (Length == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
-
         if (Length == sizeof(ENCRYPTED_NT_OWF_PASSWORD))
         {
             InfoBuffer->All.NtOwfPassword.Buffer = midl_user_allocate(sizeof(ENCRYPTED_NT_OWF_PASSWORD));
@@ -6738,6 +6749,11 @@ SampQueryUserAll(PSAM_DB_OBJECT UserObject,
                                             &Length);
             if (!NT_SUCCESS(Status))
                 goto done;
+
+            if (memcmp(InfoBuffer->All.NtOwfPassword.Buffer,
+                       &EmptyNtHash,
+                       sizeof(ENCRYPTED_NT_OWF_PASSWORD)))
+                InfoBuffer->All.NtPasswordPresent = TRUE;
         }
 
         /* Get the LM password */
@@ -6748,8 +6764,6 @@ SampQueryUserAll(PSAM_DB_OBJECT UserObject,
                                NULL,
                                &Length);
 
-        InfoBuffer->All.LmPasswordPresent = (Length == sizeof(ENCRYPTED_LM_OWF_PASSWORD));
-
         if (Length == sizeof(ENCRYPTED_LM_OWF_PASSWORD))
         {
             InfoBuffer->All.LmOwfPassword.Buffer = midl_user_allocate(sizeof(ENCRYPTED_LM_OWF_PASSWORD));
@@ -6769,6 +6783,11 @@ SampQueryUserAll(PSAM_DB_OBJECT UserObject,
                                             &Length);
             if (!NT_SUCCESS(Status))
                 goto done;
+
+            if (memcmp(InfoBuffer->All.LmOwfPassword.Buffer,
+                       &EmptyLmHash,
+                       sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
+                InfoBuffer->All.LmPasswordPresent = TRUE;
         }
     }