com.ibm.di.connector.NT4UserMetaDataConnector
Class NTMetaData

java.lang.Object
  extended by com.ibm.di.connector.NT4UserMetaDataConnector.NTMetaData

public class NTMetaData
extends Object

This class represents the Windows Users and Groups Connector JNI layer. It encapsulates all native methods to access the WinAPI functions.


Constructor Summary
NTMetaData()
           
 
Method Summary
static int getGlobalGroupsNames(String aComputerName, int aStartIndex, int aEntriesRequested, Vector aGroupsNames)
          Retrieves a "paged" list of the global groups accounts on the specified machine (should be PDC machine).
static Vector getGlobalGroupUsers(String aComputerName, String aGlobalGroupName)
          Retrieves a list of all users that are members of the global group specified.
static Vector getLocalGroupGlobalGroups(String aComputerName, String aLocalGroupName)
          Retrieves a list of all global groups that are members of the local group specified.
static Vector getLocalGroupsNames(String aComputerName)
          Retrieves a list of all local group accounts on the specified machine.
static Vector getLocalGroupUsers(String aComputerName, String aLocalGroupName)
          Retrieves a list of all users that are members of the local group specified.
static Vector getUserGlobalGroups(String aComputerName, String aUserName)
          Retrieves a list of all global groups that the specified user is member of.
static Vector getUserLocalGroups(String aComputerName, String aUserName)
          Retrieves a list of all local groups that the specified user is member of.
static int getUsersNames(String aComputerName, int aStartIndex, int aEntriesRequested, Vector aUsersNames)
          Retrieves a "paged" list of the users accounts on the specified machine.
static void globalGroupAdd(String aComputerName, GroupInfo aGroupInfo)
          Adds a global group account to the machine specified (should be PDC machine).
static void globalGroupAddUser(String aComputerName, String aGlobalGroupName, String aUserName)
          Makes the specified user member of the specified global group.
static void globalGroupDel(String aComputerName, String aGlobalGroupName)
          Removes the specified global group account from the specified machine (should be PDC machine).
static void globalGroupDelUser(String aComputerName, String aGlobalGroupName, String aUserName)
          Removes the specified user from the member list of the specified global group.
static GroupInfo globalGroupGetInfo(String aComputerName, String aGlobalGroupName)
          Retrieves all information accessible for the global group specified.
static void globalGroupSetInfo(String aComputerName, String aGlobalGroupName, GroupInfo aGroupInfo)
          Modifies global group account properties.
static void globalGroupSetUsers(String aComputerName, String aGlobalGroupName, Vector aUsers)
          Sets global group's user membership.
static boolean isPrimaryDomainController(String aComputerName)
          Checks if the machine given is a Primary Domain Controller machine.
static void localGroupAdd(String aComputerName, GroupInfo aGroupInfo)
          Adds a local group account to the machine specified.
static void localGroupAddGlobalGroups(String aComputerName, String aLocalGroupName, Vector aGlobalGroups)
          Makes the specified global groups members of the specified local group.
static void localGroupAddUsers(String aComputerName, String aLocalGroupName, Vector aUsers)
          Makes the specified users members of the specified local group.
static void localGroupDel(String aComputerName, String aLocalGroupName)
          Removes the specified local group account from the specified machine.
static void localGroupDelGlobalGroups(String aComputerName, String aLocalGroupName, Vector aGlobalGroups)
          Removes the specified global groups from the member list of the specified local group.
static void localGroupDelUsers(String aComputerName, String aLocalGroupName, Vector aUsers)
          Removes the specified users from the member list of the specified local group.
static GroupInfo localGroupGetInfo(String aComputerName, String aLocalGroupName)
          Retrieves all information accessible for the local group specified.
static void localGroupSetInfo(String aComputerName, String aLocalGroupName, GroupInfo aGroupInfo)
          Modifies local group account properties.
static void localGroupSetMembers(String aComputerName, String aLocalGroupName, Vector aMembers)
          Sets local group's user/global group membership.
static boolean logOn(String aComputerName, String aUserName, String aPassword)
          Tries to log on an arbitrary Windows machine.
static void userAdd(String aComputerName, UserInfo aUserInfo)
          Adds a user account to the machine specified.
static void userDel(String aComputerName, String aUserName)
          Removes the specified user account from the specified machine.
static UserInfo userGetInfo(String aComputerName, String aUserName)
          Retrieves all information accessible for the user specified.
static String userGetPrimaryGroup(String aComputerName, String aUserName)
          Retrieves user's Primary Group.
static void userSetGlobalGroups(String aComputerName, String aUserName, Vector aGlobalGroups)
          Sets user's global group membership.
static void userSetInfo(String aComputerName, String aUserName, UserInfo aUserInfo)
          Modifies user account properties.
static void userSetPrimaryGroup(String aComputerName, String aUserName, String aPrimaryGroup)
          Sets user's Primary Group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NTMetaData

public NTMetaData()
Method Detail

logOn

public static boolean logOn(String aComputerName,
                            String aUserName,
                            String aPassword)
                     throws NT4UserMetaDataException
Tries to log on an arbitrary Windows machine. Can be local or PDC machine in the domain as well as machine from another domain.

Parameters:
aComputerName - The name (or IP address) of the machine to log on.
aUserName - The user name of the account to log on with.
aPassword - The password of the account to log on with.
Returns:
"true" if the log on operation is successful, "false" otherwise.
Throws:
NT4UserMetaDataException - If an error occurs while trying to log on.

isPrimaryDomainController

public static boolean isPrimaryDomainController(String aComputerName)
                                         throws NT4UserMetaDataException
Checks if the machine given is a Primary Domain Controller machine.

Parameters:
aComputerName - The name (or IP address) of the machine to check for PDC.
Returns:
"true" if the machine specified is PDC, "false" otherwise.
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

userGetInfo

public static UserInfo userGetInfo(String aComputerName,
                                   String aUserName)
                            throws NT4UserMetaDataException
Retrieves all information accessible for the user specified.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account resides.
aUserName - The name of the user (the account name) which information will be retrieved.
Returns:
com.ibm.di.connector.NT4UserMetaDataConnector.UserInfo
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getUsersNames

public static int getUsersNames(String aComputerName,
                                int aStartIndex,
                                int aEntriesRequested,
                                Vector aUsersNames)
                         throws NT4UserMetaDataException
Retrieves a "paged" list of the users accounts on the specified machine.

Parameters:
aComputerName - The name (or IP address) of the machine which users will be retrieved.
aStartIndex - A resume-index for enumerating users. Specify "0" at the first call; specify function's return value on subsequent calls.
aEntriesRequested - The number of Entries requested, i.e. the "page size". Should be between 1 and 100.
aUsersNames - a java.util.Vector that will be populated with String elements each one specifying a user account name. All previous vector data is erased.
Returns:
int The resume-index that should be used on the next function's call, i.e. this value should be passed to the aStartIndex parameter on the next call. A value of "0" specifies that there are no more Entries to read.
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getUserLocalGroups

public static Vector getUserLocalGroups(String aComputerName,
                                        String aUserName)
                                 throws NT4UserMetaDataException
Retrieves a list of all local groups that the specified user is member of.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account and the local group accounts reside.
aUserName - The name of the user (the account name) which local groups will be retrieved.
Returns:
Vector of String elements each one specifying a local group account name.
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getUserGlobalGroups

public static Vector getUserGlobalGroups(String aComputerName,
                                         String aUserName)
                                  throws NT4UserMetaDataException
Retrieves a list of all global groups that the specified user is member of.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account resides.
aUserName - The name of the user (the account name) which global groups will be retrieved.
Returns:
Vector of String elements each one specifying a global group account name.
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

userAdd

public static void userAdd(String aComputerName,
                           UserInfo aUserInfo)
                    throws NT4UserMetaDataException
Adds a user account to the machine specified. If PDC machine is specified domain user will be added.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account will be added.
aUserInfo - UserInfo structure describing the user that will be added (along with all his details).
Throws:
NT4UserMetaDataException - If an error occurs while adding the user in Windows security database.

userDel

public static void userDel(String aComputerName,
                           String aUserName)
                    throws NT4UserMetaDataException
Removes the specified user account from the specified machine.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account will be removed from.
aUserName - The name of the user that will be removed.
Throws:
NT4UserMetaDataException - If an error occurs while removing the user from Windows security database.

userSetInfo

public static void userSetInfo(String aComputerName,
                               String aUserName,
                               UserInfo aUserInfo)
                        throws NT4UserMetaDataException
Modifies user account properties. Rename functionality is included in this method.

Parameters:
aComputerName - The name (or IP address) of the machine where is the user account that will be modified.
aUserName - The name of the user that will be modified.
aUserInfo - UserInfo structure describing the new user's details.
Throws:
NT4UserMetaDataException - If an error occurs while modifying the user in Windows security database.

userSetGlobalGroups

public static void userSetGlobalGroups(String aComputerName,
                                       String aUserName,
                                       Vector aGlobalGroups)
                                throws NT4UserMetaDataException
Sets user's global group membership. This method removes user's membership in all global groups and makes the user member of just the global groups specified. Can be applied just on PDC machines.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account resides (should be a PDC machine).
aUserName - The name of the user which global group membership will be set.
aGlobalGroups - Vector of String elements each one specifying the name of a global group account.
Throws:
NT4UserMetaDataException - If an error occurs while setting user's global groups membership in Windows security database.

userSetPrimaryGroup

public static void userSetPrimaryGroup(String aComputerName,
                                       String aUserName,
                                       String aPrimaryGroup)
                                throws NT4UserMetaDataException
Sets user's Primary Group. Applies just on PDC machines. If the user is not member of the global group specified, it is first added as member of this global group.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account resides (should be a PDC machine).
aUserName - The name of the user which Primary Group will be set.
aPrimaryGroup - The name of the user's new Primary Group (should be a global group).
Throws:
NT4UserMetaDataException - If an error occurs while setting user's Primary Group in Windows security database.

userGetPrimaryGroup

public static String userGetPrimaryGroup(String aComputerName,
                                         String aUserName)
                                  throws NT4UserMetaDataException
Retrieves user's Primary Group. Applies just on PDC machines.

Parameters:
aComputerName - The name (or IP address) of the machine where the user account resides (should be a PDC machine).
aUserName - The name of the user which Primary Group will be retrieved.
Returns:
String
Throws:
NT4UserMetaDataException - If an error occurs while retrieving user's Primary Group from Windows security database.

globalGroupGetInfo

public static GroupInfo globalGroupGetInfo(String aComputerName,
                                           String aGlobalGroupName)
                                    throws NT4UserMetaDataException
Retrieves all information accessible for the global group specified.

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account resides.
aGlobalGroupName - The name of the global group (the account name) which information will be retrieved.
Returns:
com.ibm.di.connector.NT4UserMetaDataConnector.GroupInfo
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getGlobalGroupsNames

public static int getGlobalGroupsNames(String aComputerName,
                                       int aStartIndex,
                                       int aEntriesRequested,
                                       Vector aGroupsNames)
                                throws NT4UserMetaDataException
Retrieves a "paged" list of the global groups accounts on the specified machine (should be PDC machine). These are in fact the global groups accessible in the whole domain.

Parameters:
aComputerName - The name (or IP address) of the PDC machine which global groups will be retrieved.
aStartIndex - A resume-index for enumerating global groups. Specify "0" at the first call; specify function's return value on subsequent calls.
aEntriesRequested - The number of Entries requested, i.e. the "page size". Should be between 1 and 100.
aGroupsNames - a java.util.Vector that will be populated with String elements each one specifying a global group account name. All previous vector data is erased.
Returns:
int The resume-index that should be used on the next function's call, i.e. this value should be passed to the aStartIndex parameter on the next call. A value of "0" specifies that there are no more Entries to read.
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getGlobalGroupUsers

public static Vector getGlobalGroupUsers(String aComputerName,
                                         String aGlobalGroupName)
                                  throws NT4UserMetaDataException
Retrieves a list of all users that are members of the global group specified.

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account resides.
aGlobalGroupName - The name of the global group (the account name) which users will be retrieved.
Returns:
Vector of String elements each one specifying a user account name.
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

globalGroupAdd

public static void globalGroupAdd(String aComputerName,
                                  GroupInfo aGroupInfo)
                           throws NT4UserMetaDataException
Adds a global group account to the machine specified (should be PDC machine).

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account will be added.
aGroupInfo - GroupInfo structure describing the global group that will be added (along with all its details).
Throws:
NT4UserMetaDataException - If an error occurs while adding the global group in Windows security database.

globalGroupAddUser

public static void globalGroupAddUser(String aComputerName,
                                      String aGlobalGroupName,
                                      String aUserName)
                               throws NT4UserMetaDataException
Makes the specified user member of the specified global group.

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account resides.
aGlobalGroupName - The name of the global group where the user will be added as member.
aUserName - The name of the user that will be added as member of the global group.
Throws:
NT4UserMetaDataException - If an error occurs while adding member in the global group.

globalGroupDel

public static void globalGroupDel(String aComputerName,
                                  String aGlobalGroupName)
                           throws NT4UserMetaDataException
Removes the specified global group account from the specified machine (should be PDC machine).

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account will be removed from.
aGlobalGroupName - The name of the global group that will be removed.
Throws:
NT4UserMetaDataException - If an error occurs while removing the global group from Windows security database.

globalGroupDelUser

public static void globalGroupDelUser(String aComputerName,
                                      String aGlobalGroupName,
                                      String aUserName)
                               throws NT4UserMetaDataException
Removes the specified user from the member list of the specified global group.

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account resides.
aGlobalGroupName - The name of the global group account.
aUserName - The name of the user that will be removed from the global group's members.
Throws:
NT4UserMetaDataException - If an error occurs while removing the user from the global group members list.

globalGroupSetUsers

public static void globalGroupSetUsers(String aComputerName,
                                       String aGlobalGroupName,
                                       Vector aUsers)
                                throws NT4UserMetaDataException
Sets global group's user membership. This method cancels all users' membership in the global group specified and makes the users specified members of the global group.

Parameters:
aComputerName - The name (or IP address) of the PDC machine where the global group account resides.
aGlobalGroupName - The name of the global group which user membership will be set.
aUsers - Vector of String elements each one specifying the name of a user account.
Throws:
NT4UserMetaDataException - If an error occurs while setting global group's user membership in Windows security database.

globalGroupSetInfo

public static void globalGroupSetInfo(String aComputerName,
                                      String aGlobalGroupName,
                                      GroupInfo aGroupInfo)
                               throws NT4UserMetaDataException
Modifies global group account properties. Rename functionality is included in this method.

Parameters:
aComputerName - The name (or IP address) of the PDC machine where is the global group account that will be modified.
aGlobalGroupName - The name of the global group that will be modified.
aGroupInfo - GroupInfo structure describing the new global group's details.
Throws:
NT4UserMetaDataException - If an error occurs while modifying the global group in Windows security database.

localGroupGetInfo

public static GroupInfo localGroupGetInfo(String aComputerName,
                                          String aLocalGroupName)
                                   throws NT4UserMetaDataException
Retrieves all information accessible for the local group specified.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group (the account name) which information will be retrieved.
Returns:
com.ibm.di.connector.NT4UserMetaDataConnector.GroupInfo
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getLocalGroupsNames

public static Vector getLocalGroupsNames(String aComputerName)
                                  throws NT4UserMetaDataException
Retrieves a list of all local group accounts on the specified machine.

Parameters:
aComputerName - The name (or IP address) of the machine which local groups will be retrieved.
Returns:
Vector of String elements each one specifying a local group account name.
Throws:
NT4UserMetaDataException - If an error occurred while querying the machine specified.

getLocalGroupUsers

public static Vector getLocalGroupUsers(String aComputerName,
                                        String aLocalGroupName)
                                 throws NT4UserMetaDataException
Retrieves a list of all users that are members of the local group specified.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group (the account name) which users will be retrieved.
Returns:
Vector of String elements each one specifying a user account name. Account names are returned in the following format: domain users - \; non-domain users - .
Throws:
NT4UserMetaDataException - If an error occurs while querying the machine specified.

getLocalGroupGlobalGroups

public static Vector getLocalGroupGlobalGroups(String aComputerName,
                                               String aLocalGroupName)
                                        throws NT4UserMetaDataException
Retrieves a list of all global groups that are members of the local group specified.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group (the account name) which global groups will be retrieved.
Returns:
Vector of String elements each one specifying a global group account name. Account names are returned in the following format: \.
Throws:
NT4UserMetaDataException - If an error occured while quering the machine specified.

localGroupAdd

public static void localGroupAdd(String aComputerName,
                                 GroupInfo aGroupInfo)
                          throws NT4UserMetaDataException
Adds a local group account to the machine specified.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account will be added.
aGroupInfo - GroupInfo structure describing the local group that will be added (along with all its details).
Throws:
NT4UserMetaDataException - If an error occurs while adding the local group in Windows security database.

localGroupDel

public static void localGroupDel(String aComputerName,
                                 String aLocalGroupName)
                          throws NT4UserMetaDataException
Removes the specified local group account from the specified machine.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account will be removed from.
aLocalGroupName - The name of the local group that will be removed.
Throws:
NT4UserMetaDataException - If an error occurs while removing the local group from Windows security database.

localGroupAddUsers

public static void localGroupAddUsers(String aComputerName,
                                      String aLocalGroupName,
                                      Vector aUsers)
                               throws NT4UserMetaDataException
Makes the specified users members of the specified local group.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group where the users will be added as members.
aUsers - Vector of String elements each one specifying the name of a user to be added as member of the local group. Domain users should be specified in the format \; non-domain users can be specified either by \ or just by .
Throws:
NT4UserMetaDataException - If an error occurs while adding members in the local group.

localGroupAddGlobalGroups

public static void localGroupAddGlobalGroups(String aComputerName,
                                             String aLocalGroupName,
                                             Vector aGlobalGroups)
                                      throws NT4UserMetaDataException
Makes the specified global groups members of the specified local group.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group where the global groups will be added as members.
aGlobalGroups - Vector of String elements each one specifying the name of a global group to be added as member of the local group. Global group names can be specified either in the format \ or just by .
Throws:
NT4UserMetaDataException - If an error occurs while adding members in the local group.

localGroupDelUsers

public static void localGroupDelUsers(String aComputerName,
                                      String aLocalGroupName,
                                      Vector aUsers)
                               throws NT4UserMetaDataException
Removes the specified users from the member list of the specified local group.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group account.
aUsers - Vector of String elements each one specifying the name of a user to be removed from the local group's members. User names can be specified either in the format \ or just by .
Throws:
NT4UserMetaDataException - If an error occurs while removing the users from the local group members list.

localGroupDelGlobalGroups

public static void localGroupDelGlobalGroups(String aComputerName,
                                             String aLocalGroupName,
                                             Vector aGlobalGroups)
                                      throws NT4UserMetaDataException
Removes the specified global groups from the member list of the specified local group.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group account.
aGlobalGroups - Vector of String elements each one specifying the name of a global group to be removed from the local group's members. Global group names can be specified either in the format \ or just by .
Throws:
NT4UserMetaDataException - If an error occurs while removing the global groups from the local group members list.

localGroupSetInfo

public static void localGroupSetInfo(String aComputerName,
                                     String aLocalGroupName,
                                     GroupInfo aGroupInfo)
                              throws NT4UserMetaDataException
Modifies local group account properties. Rename functionality is included in this method.

Parameters:
aComputerName - The name (or IP address) of the machine where is the local group account that will be modified.
aLocalGroupName - The name of the local group that will be modified.
aGroupInfo - GroupInfo structure describing the new local group's details.
Throws:
NT4UserMetaDataException - If an error occurs while modifying the local group in Windows security database.

localGroupSetMembers

public static void localGroupSetMembers(String aComputerName,
                                        String aLocalGroupName,
                                        Vector aMembers)
                                 throws NT4UserMetaDataException
Sets local group's user/global group membership. This method cancels all users' and global groups' membership in the local group specified and makes the users and global groups specified members of the local group.

Parameters:
aComputerName - The name (or IP address) of the machine where the local group account resides.
aLocalGroupName - The name of the local group which membership will be set.
aMembers - Vector of String elements each one specifying the name of either a user or a global group account. Domain members (users or groups) should be specified in the format \; non-domain users can be specified either by \ or just by .
Throws:
NT4UserMetaDataException - If an error occurs while setting local group's membership in Windows security database.