To see the available roles, you can run the following command on an already provisioned ESXi host:
vim-cmd vimsvc/auth/roles | less
The default roles on an ESXi host are:
- NoAccess
- ReadOnly
- Admin
vim-cmd vimsvc/auth/permissions
These entries will match what you see in the vSphere Client and dictate who has login access to the ESXi host.
To add a new permission, we will be using the "vim-cmd vimsvc/auth/entity_permission_add" and it requires five parameters.
- First - Entity (This can be found by looking at the output from permissions)
- Second - Username
- Third - Boolean on whether this is a group or not (should be false)
- Fourth - The role to be applied to the user
- Fifth - Boolean on whether to propagate this permission
Note: We need to use the double slash "\" to escape the initial slash when running the query. Also make note of the domain name as it may or may not match your full domain name.
We are now ready to craft a simple script that will add domain users as part of the ESXi kickstart process. The following snippet should be placed in the %firstboot section of your kickstart and after your Active Directory domain join code. Make sure you replace the DOMAIN_NAME variable along with the usernames. In the example I have two separate for loops to handle ReadOnly and Admin users, you do not need both if you are only adding one type of users.
The script basically performs a simple 60sec sleep to ensure the domain join process has completed before continuing. If you do not place a sleep, the subsequent code will fail to execute. The next step is to validate the user by doing a simple lookup using "id" command and upon successful look up of the user, we add the appropriate permissions.
Note: We only have two add these two entities: "vim.Folder:ha-folder-root" and "vim.ComputeResource:ha-compute-res" to properly add a permission.
If everything was successful, after your ESXi installation you now should have your host joined to your Active Directory and a list of domain users who now have permission to login to the ESXi host. You can verify by using the vSphere Client and taking a look at the Permissions tab.
If you would like to create custom roles on your ESXi host, you can use the following command:
If everything was successful, after your ESXi installation you now should have your host joined to your Active Directory and a list of domain users who now have permission to login to the ESXi host. You can verify by using the vSphere Client and taking a look at the Permissions tab.
If you would like to create custom roles on your ESXi host, you can use the following command:
vim-cmd vimsvc/auth/role_add
Note: The syntax for the privileges parameter lists only five, but it actually accepts as many as you need with the custom role












'id' command will not work for AD users and groups. Instead 'lw-lsa' command can be used.
ReplyDeleteE.g.
lw-lsa find-group-by-name --level 0 "${GROUP}" > /dev/null 2>&1
if [ $? -eq 0 ]; then
vim-cmd vimsvc/auth/entity_permission_add "vim.Folder:ha-folder-root" "${GROUP}" true Admin true
vim-cmd vimsvc/auth/entity_permission_add "vim.ComputeResource:ha-compute-res" "${GROUP}" true Admin true
fi