VMware {code} Community
reflexes
Contributor
Contributor

How can I create a user in VCenter Server, using vim25?

I can create a user account through the web client.

But I want to create users, using vim25 SDK(JAVA).

I can retrieve user information from UserDirectory(retriveUserGroups method) but I couldn't find the method to create a user in vCenter server.

HostLocalAccountManager  only works for ESXi.

Any suggestions?

I will really appreciate your help! Thanks!

0 Kudos
2 Replies
doskiran
Enthusiast
Enthusiast

Yes HostLocalAccountManager works only for ESXi, it will throw null for VC session (si.getAccountManager())

Use SSH commands to create users and groups on linux or windows VC,

Commands for Linux VC:

// Add new group

> pi shell groupadd groupname

// Add new user

pi shell useradd -g " + group + " " + user
+ " -p `openssl passwd -crypt "
+ TestConstants.PASSWORD + "`"

> pi shell useradd -g  group  user  -p `openssl passwd -crypt password`

Commands for Windows VC:

// Add new user

> net user username password  /ADD /EXPIRES:NEVER

// Add new group

> net localgroup group /ADD 

// Assign the user to the group

> net localgroup group  user  /ADD 

0 Kudos
doskiran
Enthusiast
Enthusiast

Use ganymed-ssh2-build210.jar SSH java api's to run those commands remotly.
0 Kudos