Author: ekohl
Date: Wed Jul 30 20:59:53 2014
New Revision: 63786
URL:
http://svn.reactos.org/svn/reactos?rev=63786&view=rev
Log:
[SAMLIB]
SampCheckPassword: Implement the character class check.
Modified:
trunk/reactos/dll/win32/samlib/precomp.h
trunk/reactos/dll/win32/samlib/samlib.c
Modified: trunk/reactos/dll/win32/samlib/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/precomp.h…
==============================================================================
--- trunk/reactos/dll/win32/samlib/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samlib/precomp.h [iso-8859-1] Wed Jul 30 20:59:53 2014
@@ -9,5 +9,6 @@
#include <windef.h>
#include <winbase.h>
+#include <winnls.h>
#endif /* _SAMLIB_PCH_ */
Modified: trunk/reactos/dll/win32/samlib/samlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/samlib.c?…
==============================================================================
--- trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] Wed Jul 30 20:59:53 2014
@@ -128,8 +128,11 @@
IN PUNICODE_STRING Password)
{
USER_DOMAIN_PASSWORD_INFORMATION DomainPasswordInformation;
+ LPWORD CharTypeBuffer = NULL;
ULONG PasswordLength;
- NTSTATUS Status;
+ ULONG i;
+ ULONG Upper = 0, Lower = 0, Digit = 0, Punct = 0, Alpha = 0;
+ NTSTATUS Status = STATUS_SUCCESS;
TRACE("(%p %p)\n", UserHandle, Password);
@@ -152,10 +155,57 @@
/* Check the password complexity */
if (DomainPasswordInformation.PasswordProperties & DOMAIN_PASSWORD_COMPLEX)
{
- /* FIXME */
- }
-
- return STATUS_SUCCESS;
+ CharTypeBuffer = midl_user_allocate(PasswordLength * sizeof(WORD));
+ if (CharTypeBuffer == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ GetStringTypeW(CT_CTYPE1,
+ Password->Buffer,
+ PasswordLength,
+ CharTypeBuffer);
+
+ for (i = 0; i < PasswordLength; i++)
+ {
+ TRACE("%lu: %C %s %s %s %s\n", i, Password->Buffer[i],
+ (CharTypeBuffer[i] & C1_UPPER) ? "C1_UPPER" : "
",
+ (CharTypeBuffer[i] & C1_LOWER) ? "C1_LOWER" : "
",
+ (CharTypeBuffer[i] & C1_DIGIT) ? "C1_DIGIT" : "
",
+ (CharTypeBuffer[i] & C1_PUNCT) ? "C1_PUNCT" : "
",
+ (CharTypeBuffer[i] & C1_ALPHA) ? "C1_ALPHA" : "
");
+
+ if (CharTypeBuffer[i] & C1_UPPER)
+ Upper = 1;
+
+ if (CharTypeBuffer[i] & C1_LOWER)
+ Lower = 1;
+
+ if (CharTypeBuffer[i] & C1_DIGIT)
+ Digit = 1;
+
+ if (CharTypeBuffer[i] & C1_PUNCT)
+ Punct = 1;
+
+ if ((CharTypeBuffer[i] & C1_ALPHA) &&
+ !(CharTypeBuffer[i] & C1_UPPER) &&
+ !(CharTypeBuffer[i] & C1_LOWER))
+ Alpha = 1;
+ }
+
+ TRACE("Upper: %lu\n", Upper);
+ TRACE("Lower: %lu\n", Lower);
+ TRACE("Digit: %lu\n", Digit);
+ TRACE("Punct: %lu\n", Punct);
+ TRACE("Alpha: %lu\n", Alpha);
+
+ TRACE("Total: %lu\n", Upper + Lower + Digit + Punct + Alpha);
+ if (Upper + Lower + Digit + Punct + Alpha < 3)
+ Status = STATUS_PASSWORD_RESTRICTION;
+ }
+
+ if (CharTypeBuffer != NULL)
+ midl_user_free(CharTypeBuffer);
+
+ return Status;
}