Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcsim: Add HostLocalAccountManager #959

Merged
merged 1 commit into from
Dec 13, 2017
Merged

Conversation

anfernee
Copy link
Contributor

Support CUD operations on users. Groups operations are not supported
because they are deprecated in 5.1

Fix #947

Support CUD operations on users. Groups operations are not supported
because they are deprecated in 5.1

Fix vmware#947
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@anfernee anfernee merged commit cabbd96 into vmware:master Dec 13, 2017
@Akasurde
Copy link
Contributor

@dougm @anfernee Thanks for support. Will check once.

@Akasurde
Copy link
Contributor

Akasurde commented Dec 13, 2017

I am not able list down all users using RetrieveUserGroups API

Here is snippet to reproduce -

from __future__ import print_function

from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vim

import argparse
import atexit
import getpass
import ssl

host='172.17.0.2'
user='user'
password='pass'

context = ssl._create_unverified_context()
si = SmartConnect(host=host,
                  user=user,
                  pwd=password,
                  sslContext=context)
atexit.register(Disconnect, si)

content = si.RetrieveContent()

# Add user
local_user = 'testuser0003'
local_pass = 'Esxi$123$'
account_spec = vim.host.LocalAccountManager.AccountSpecification()
account_spec.id = local_user
account_spec.password = local_pass
account_spec.description = local_user


content.accountManager.CreateUser(account_spec)

# Search user
user_account = content.userDirectory.RetrieveUserGroups(domain='', searchStr=local_user, exactMatch=False, findUsers=True, findGroups=True)
print(user_account)

# List all users
user_account = content.userDirectory.RetrieveUserGroups(domain='', searchStr='', exactMatch=False, findUsers=True, findGroups=True)
print(user_account)

Output is

(vim.UserSearchResult) []
(vim.UserSearchResult) [
   (vim.UserSearchResult) {
      dynamicType = <unset>,
      dynamicProperty = (vmodl.DynamicProperty) [],
      principal = 'root',
      fullName = 'root',
      group = true
   },
   (vim.UserSearchResult) {
      dynamicType = <unset>,
      dynamicProperty = (vmodl.DynamicProperty) [],
      principal = 'root',
      fullName = 'root',
      group = false
   },
   (vim.UserSearchResult) {
      dynamicType = <unset>,
      dynamicProperty = (vmodl.DynamicProperty) [],
      principal = 'admin',
      fullName = 'administrator',
      group = false
   }
]

@anfernee
Copy link
Contributor Author

It'll be great to have the script to reproduce. I'll check the result today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants