PwdFilt

This is a discussion on PwdFilt within the C Programming forums, part of the General Programming Boards category; I have downloaded and have been playing around with the PasswordFilters sample which is found in the Microsoft Platform SDK.
...

PwdFilt

I have downloaded and have been playing around with the PasswordFilters sample which is found in the Microsoft Platform SDK.

As a VB.NET developer, I am stumped as to how to modify this to allow for a minimum of 1 letter (a-z) or 1 special character (#,$,@,_) AND 1 number. The letters and numbers are not a problem. It is detecting the 4 special characters which I am having problems with.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

As previously mentioned, I have downloaded and have been playing around with the PasswordFilters sample which is found in the Microsoft Platform SDK.

I would like to modify this function to allow for a minimum of 1 letter (a-zA-Z) or 1 special character (#,$,@,_) AND 1 number. The letters and numbers are not a problem. It is detecting the 4 special characters which I am having problems with.

GetStringTypeW is used to get the character type from a PUNICODE_STRING. If the type is NOT C1_ALPHA or C1_DIGIT, we would like to look at the actual character value (from PUNICODE_STRING) to determine if it is one of (#,$,@,_). If it is NOT any of these characters, then an invalid character has been entered and we would break out of the loop and return FALSE to indicate an invalid password.

So I think the question then is, what kind of characters you're using? '#', '$', etc. are just plain chars. If you're using wchar_t or tchar, then you would need to use character literals of the same type.

From what I understand (through reading and testing), is that this function gets called whenever a user (or admin) attempts to change an Active Directory password. We would like to validate the newly entered password to ensure that it meets our criteria (mentioned above). As a .NET programmer, I am not sure on how to get, and compare, the character values associated with the Password->Buffer pointer.

Inside of the loop, Password->Buffer[i] does not work. This is a pointer and not the actual character value. I am unsure on how to get the character to which the pointer is referencing.

You keep saying this, but it is not in fact true. Password->Buffer is a pointer, yes. Password->Buffer[i] is a character -- specifically, it's a wide character. So, for instance (excuse the mix of C++ and C):

In other words, I don't get any syntax errors from your original code, and as much as I am able to test it it works correctly. If you are having problems, you will have to break down and actually tell us what they are.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell