Package com.install4j.api.windows
Class WinUser
- java.lang.Object
-
- com.install4j.api.windows.WinUser
-
public class WinUser extends java.lang.ObjectCollection 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
Nested Classes Modifier and Type Class Description static classWinUser.AddUserResultThe 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 classWinUser.AddUserResultTypestatic classWinUser.GroupCreationModeThe group creation mode.
-
Constructor Summary
Constructors Constructor Description WinUser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static WinUser.AddUserResultaddUser(java.lang.String name, java.lang.String password, java.lang.String comment, WinUser.GroupCreationMode groupCreationMode, java.lang.String localGroupNameOrSid, java.lang.String localGroupComment)Add a user and optionally a local group.static booleandeleteLocalGroup(java.lang.String nameOrSid)Delete a local group.static booleandeleteUser(java.lang.String nameOrSid)Delete a user.static java.lang.StringgetAccountName(java.lang.String sid)Try to get an account name for a SID (Security Identifier).static java.lang.StringgetUserName(java.lang.String sid)Try to get the user name (an unqualified account name) for a SID (Security Identifier).static java.lang.StringgetUserSid()Get the users SID (Security Identifier) of the current process.
-
-
-
Method Detail
-
deleteUser
public static boolean deleteUser(java.lang.String nameOrSid)
Delete a user.- Parameters:
nameOrSid- an account name or a SID in String form- Returns:
trueif successful or if the user doesn't exist
-
deleteLocalGroup
public static boolean deleteLocalGroup(java.lang.String nameOrSid)
Delete a local group.- Parameters:
nameOrSid- an account name or a SID in String form- Returns:
trueif successful or if the local group doesn't exist
-
addUser
public static WinUser.AddUserResult addUser(java.lang.String name, java.lang.String password, java.lang.String comment, WinUser.GroupCreationMode groupCreationMode, java.lang.String localGroupNameOrSid, java.lang.String localGroupComment)
Add a user and optionally a local group.- Parameters:
name- the user namepassword- the password for the accountcomment- an optional comment. Can benullgroupCreationMode- how the group should be createdlocalGroupNameOrSid- a group name or optionally a SID if the group already exists. Can benullforWinUser.GroupCreationMode.NONE.localGroupComment- an optional comment for the local group. Can benull- Returns:
- the result of the operation
-
getAccountName
public static java.lang.String getAccountName(java.lang.String sid)
Try to get an account name for a SID (Security Identifier).- Parameters:
sid- the SID in String form- Returns:
- A qualified account name or
nullif the account could not be found.
-
getUserName
public static java.lang.String getUserName(java.lang.String sid)
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
nullif the account could not be found.
-
getUserSid
public static java.lang.String getUserSid()
Get the users SID (Security Identifier) of the current process.- Returns:
- A SID in String form or
nullif the method fails.
-
-