Thread: UserMgr Plugin
View Single Post
Old 29th May 2021, 19:45   #55
Kanelo
Junior Member
 
Join Date: Mar 2021
Posts: 2
very usefull plugin but i missed a password validation function and the possibility to use SID Groups directly as GetLocalizedStdAccountName did not do the trick for me.

AddToGroup, IsMemberOfGroup and RemoveFromGroup now checks if GroupID is in square Brackets "[]", if so it is treated as SID.

This will Add, check and remove user Test to builtin\administrators
For this test a User "Test" is needed
PHP Code:
    UserMgr::IsMemberOfGroup "Test" "[S-1-5-32-544]"
    
Pop $0
    DetailPrint 
"$$0: $0"
    
    
UserMgr::AddToGroup  "Test" "[S-1-5-32-544]"
    
Pop $0
    DetailPrint 
"$$0: $0"
    
    
UserMgr::IsMemberOfGroup "Test" "[S-1-5-32-544]"
    
Pop $0
    DetailPrint 
"$$0: $0"
    
    
UserMgr::RemoveFromGroup "Test" "[S-1-5-32-544]"
    
Pop $0
    DetailPrint 
"$$0: $0"
    
    
UserMgr::IsMemberOfGroup "Test" "[S-1-5-32-544]"
    
Pop $0
    DetailPrint 
"$$0: $0" 
As it should be a non invasive modification there should be no need to change existing code!
(the idea/methode is copied from AccessControl. Thanks )


New Function ValidatePassword checks if the given password will be accepted on a given system.
PHP Code:
UserMgr::ValidatePassword "password1234" "local" 
Checks if "password1234" will be accepted on the local machine. You can also type the name of a valid remote server for validation over network.
PHP Code:
UserMgr::ValidatePassword "password1234" "dc.example.org" 
The Function places the return on top of the Stack. Return is "ERROR XXXX" or "OK".
Error codes can be found here Network Management Error Codes

NOTE: NERR_PasswordTooShort (2245) will sometimes be thrown if the password matches or contains the username. This can not be checked beforehand with this function as there is no username given.

Some code review would be appreciated.
If i don't hear anything wrong, i or hopefully one more experienced user will update the wiki page.


NOTEĀ²: I used VS2019 to compile this, so if you use the included unicode/ansi dll file you need to install "Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019" before the use on a machine!

Bonus
Fixed: RemoveFromGroup, didn't work with NetGroupDelUser (at least on Windows 10)


Famous last words: Works for me
Attached Files
File Type: zip UserMgr.zip (45.9 KB, 3199 views)
Kanelo is offline   Reply With Quote