Creating and deleting users and groups

Posted: 3 May 2009 in CSSDK, Groups, Java, Security, Teamsite, Users

The CSPrincipalManager is the class responsible with creating users and groups. If we want to create a user, we call the createTSUser() method and likewise, we call the createTSGroup() method to create a group.

CSPrincipalManager principalManager=client.getPrincipalManager();
String name="johndoe";
int kind=CSUser.TS_OS_USER;
String password=null;
String displayName="John Doe";
String description="We don't really know who John Doe really is.";
String emailAddress="john.doe@acme.com";
String preferredUI=CSUser.PREFERRED_UI_CCSTD_ONLY;
boolean isMaster=false;

CSUser someUser=principalManager.createTSUser(name, kind, password, displayName, description, emailAddress, preferredUI,isMaster);

the kind referes to the type of users. As of 6.7.2, users can be non-OS users. This is entered as an  int represented by class constants such as CSUser.TS_OS_USER. For the prefered interface, the CSUser class also provides some constants such as CSUser.PREFERRED_UI_CCSTD_ONLY.

CSPrincipalManager principalManager=client.getPrincipalManager();

String name="marketing";
CSUser[] users=new CSUser[0];
CSGroup[] groups=new CSGroup[0];
CSUser[] admins={client.getcurrentUser()};
String displayName="The marketing team";
String description="The marketing team provides leadership, sales support, promotions and market relations";

CSGroup someGroup = principalManager.createTSGroup(name, users, groups, admins, displayName,description);

Deleting a user or a group is simply done by invoking the delete() method on the object

if (someUser!=null){
    someUser.delete();
}
if (someGroup!=null){
    someGroup.delete();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s