Package com.install4j.api.windows
Class WinUser
java.lang.Object
com.install4j.api.windows.WinUser
Collection of static methods to create or delete users and local groups on Windows.
If a helper process with elevated privileges has been created by the "Request privileges" action, the methods of this class are pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The class of the objects returned byaddUser(java.lang.String, java.lang.String, java.lang.String, com.install4j.api.windows.WinUser.GroupCreationMode, java.lang.String, java.lang.String)
.static enum
static enum
The group creation mode. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic WinUser.AddUserResult
addUser
(String name, String password, String comment, WinUser.GroupCreationMode groupCreationMode, String localGroupNameOrSid, String localGroupComment) Add a user and optionally a local group.static boolean
deleteLocalGroup
(String nameOrSid) Delete a local group.static boolean
deleteUser
(String nameOrSid) Delete a user.static String
getAccountName
(String sid) Try to get an account name for a SID (Security Identifier).static String
getUserName
(String sid) Try to get the user name (an unqualified account name) for a SID (Security Identifier).static String
Get the users SID (Security Identifier) of the current process.
-
Constructor Details
-
WinUser
public WinUser()
-
-
Method Details
-
deleteUser
Delete a user.- Parameters:
nameOrSid
- an account name or a SID in String form- Returns:
true
if successful or if the user doesn't exist
-
deleteLocalGroup
Delete a local group.- Parameters:
nameOrSid
- an account name or a SID in String form- Returns:
true
if successful or if the local group doesn't exist
-
addUser
public static WinUser.AddUserResult addUser(String name, String password, String comment, WinUser.GroupCreationMode groupCreationMode, String localGroupNameOrSid, String localGroupComment) Add a user and optionally a local group.- Parameters:
name
- the user namepassword
- the password for the accountcomment
- an optional comment. Can benull
groupCreationMode
- how the group should be createdlocalGroupNameOrSid
- a group name or optionally a SID if the group already exists. Can benull
forWinUser.GroupCreationMode.NONE
.localGroupComment
- an optional comment for the local group. Can benull
- Returns:
- the result of the operation
-
getAccountName
Try to get an account name for a SID (Security Identifier).- Parameters:
sid
- the SID in String form- Returns:
- A qualified account name or
null
if the account could not be found.
-
getUserName
Try to get the user name (an unqualified account name) for a SID (Security Identifier).- Parameters:
sid
- the SID in String form- Returns:
- An unqualified account name or
null
if the account could not be found.
-
getUserSid
Get the users SID (Security Identifier) of the current process.- Returns:
- A SID in String form or
null
if the method fails.
-