Old 28th January 2009, 17:49   #41
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Well, as far I can see I'm doing exactly the same.
And there is nothing wrong with the parameters I'm passing to LsaEnumerateAccountRights, since it returns no error if the user does have privileges.
jpderuiter is offline   Reply With Quote
Old 2nd September 2009, 18:46   #42
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
I uploaded a new version of this plugin:
- Added GetUserNameFromSID function
- Added GetSIDFromUserName function
- Fixed a problem in the RegLoadUserHive function when a user was deleted and then recreated
Quote:
Originally posted by TobbeSweden
Now I can run the plugin but there is one thing I find weird...
code:
Name "UsrMgrTest"
OutFile "UsrMgrTest.exe"
ShowInstDetails show
Page instfiles

Section ""
UserMgr::GetCurrentUserName
Pop $0
DetailPrint ">$0<"
UserMgr::GetUserInfo $0 "HOMEDIR"
Pop $1
DetailPrint ">$1<"
UserMgr::HasPrivilege $0 "SeInteractiveLogonRight"
Pop $2
DetailPrint ">$2<"
SectionEnd


$1 is just an empty string when I run that. And $2 is "ERROR LsaEnumerateAccountRights". $0 does contain my username.
Thanks to ginglese I found a better way to get the HOMEDIR:http://forums.winamp.com/showthread....postid=2558509
code:
UserMgr::GetCurrentUserName
Pop $0
UserMgr::GetSIDFromUserName "" $0
Pop $1
ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$1" "ProfileImagePath"
ExpandEnvStrings $3 $2
DetailPrint "Homedir: $3"

jpderuiter is offline   Reply With Quote
Old 1st September 2011, 19:59   #43
langdon
Junior Member
 
Join Date: May 2006
Posts: 17
Having some trouble with this plugin on my work machine (which is joined to a domain, and I'm logged with a domain account). I keep getting ERROR 2221 (NERR_UserNotFound) from the following:

PHP Code:
UserMgr::GetUserInfo "domain\username" "exists"
Pop $0
MessageBox MB_OK 
"$0"
UserMgr::GetSIDFromUserName "domain" "username"
Pop $1
MessageBox MB_OK 
"$1" 
1st MessageBox: "ERROR 2221"
2nd MessageBox: "ERROR GetAccountSid"

There's a slight delay when calling GetSIDFromUserName (like 1-2 seconds).

I've double and triple checked that I have the correct domain and username. I even went as far as pulling the SID from the registry and calling it sequence:

PHP Code:
UserMgr::GetUserNameFromSID "S-1-5-21-4264112824-276356272-3790957511-1754"
Pop $0
MessageBox MB_OK 
"$0"
UserMgr::GetUserInfo "$0" "exists"
Pop $1
MessageBox MB_OK 
"$1" 
I still get ERROR 2221 (NERR_UserNotFound) with this.

Any ideas?
langdon is offline   Reply With Quote
Old 1st September 2011, 21:24   #44
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Hi,

what do you get when using the GetCurrentUserName and GetCurrentDomain functions?

And what do you get when using the following command in the DOS cmd:
net user {username} /domain
(replace {username} with your username)?

JP
jpderuiter is offline   Reply With Quote
Old 1st September 2011, 21:40   #45
langdon
Junior Member
 
Join Date: May 2006
Posts: 17
Re: GetCurrentUserName/Domain, these are identical:

PHP Code:
UserMgr::GetUserNameFromSID "S-1-5-21-4264112824-276356272-3790957511-1754"
Pop $0
UserMgr
::GetCurrentDomain 
Pop 
$1
UserMgr
::GetCurrentUserName
Pop 
$2
MessageBox MB_OK 
"$0 vs $1\$2" 
The net user command tells somewhat of a different tale -- it appends ".com" onto the domain when it describes the request.

Going back and changing the code above to domain.com\username, still gets me the error, BUT calling GetSIDFromUsername with domain.com and my username, yields the correct SID.

What do you make of this?

Quote:
C:\Users\oliverlw>net user oliverlw /domain
The request will be processed at a domain controller for domain xxxx.com.

User name xxxx
Full Name xxxx xxxx
Comment
User's comment
Country code 000 (System Default)
Account active Yes
Account expires Never

Password last set 8/5/2011 7:56:20 AM
Password expires 11/3/2011 7:56:20 AM
Password changeable 8/6/2011 7:56:20 AM
Password required Yes
User may change password Yes

Workstations allowed All
Logon script
User profile
Home directory
Last logon 9/1/2011 3:28:51 PM

Logon hours allowed All

Local Group Memberships
Global Group memberships *xxxx

The command completed successfully.
langdon is offline   Reply With Quote
Old 1st September 2011, 21:42   #46
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Sorry, I was too quick to answer.

The reason is GetUserInfo only works for local accounts...
The plugin should be updated to support domain users for GetUserInfo.
You can try to use the system plugin to get the information you need:
http://forums.winamp.com/showpost.ph...1&postcount=14
Search for NetUserGetInfo in that post.
jpderuiter is offline   Reply With Quote
Old 1st September 2011, 21:47   #47
langdon
Junior Member
 
Join Date: May 2006
Posts: 17
Ahh, thanks, I'll give that a whirl.

I posted a response to your questions, but it's pending moderator approval?
langdon is offline   Reply With Quote
Old 15th July 2014, 11:47   #48
rvintonyak
Junior Member
 
Join Date: Jul 2014
Posts: 3
Hi folks.

Currently I'm working on creating unicode nsis installer. In ansi version of installer I use UserMgr.dll to receive username and user SID.

For unicode installer I need UserMgr.dll to be compiled as unicode too.

So I'm just curious if I can download somewhere unicode UserMgr.dll or should I download sources and construct it by myself?

Thanks,
Roman
rvintonyak is offline   Reply With Quote
Old 15th July 2014, 12:00   #49
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Unfortunately there is no Unicode version available yet.
And I don't have time to do the port any time soon...
jpderuiter is offline   Reply With Quote
Old 15th July 2014, 12:35   #50
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
I've had a quick look at the code and it doesn't seem too hard. It's just the sheer quantity that's the time consuming part. I'll play around with it and see what I can do.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 15th July 2014, 18:45   #51
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
So I've added unicode support to this plugin, but I haven't done any testing yet.

I used VS2008 for the development, and I've included the project file along with all the source files and compiled release versions. I used C runtime calls as much as I could, so the source should compile on older compilers with little or no modifications.
Attached Files
File Type: zip UsrMgr-unicode-test.zip (39.0 KB, 305 views)

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 15th July 2014, 23:25   #52
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Hi Jason,

thanks for your update.

Did you change the plugin name on purpose from UserMgr to UsrMgr?
Now existing scripts are broken.

After changing the plugin file name, the UserMgr plugin is working fine in Unicode and Ansi.

Thanks again!

JP
jpderuiter is offline   Reply With Quote
Old 16th July 2014, 00:02   #53
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
Whoops, that's a typo on my behalf. But yeah, I haven't tested it, so that's why I didn't notice the name was wrong. Consider this a patch that will hopefully get merged at some point (I was only going to upload the usermgr.c file).

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 16th July 2014, 09:11   #54
rvintonyak
Junior Member
 
Join Date: Jul 2014
Posts: 3
Thanks a lot, Jason!
rvintonyak is offline   Reply With Quote
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, 3132 views)
Kanelo is offline   Reply With Quote
Old 30th May 2021, 12:09   #56
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
Quote:
Originally Posted by Kanelo View Post
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!
That's easy to fix, in the project settings under code generation, change the runtime library to /MT. That statically links the C/C++ runtime so that it runs on any machine. The downside is that it increases the size of the DLL alot, but for compatibility it's a compromise worth doing.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 30th May 2021, 15:37   #57
Kanelo
Junior Member
 
Join Date: Mar 2021
Posts: 2
didn't know that, thank you
Attached Files
File Type: zip UserMgr.zip (148.8 KB, 95 views)
Kanelo is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump