ZenDMD Tip - Add Roles to Users in a jiffy

From Zenoss Wiki
Revision as of 14:17, 20 November 2013 by Crouthamela (Talk | contribs)$7

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

On the master, `su zenoss` then `zendmd`

usersToEdit are the usernames to add roles to.

usersToEdit = ['User1', 'User2', 'User3']
roles = ['ZenManager',]
roleManager = dmd.acl_users.roleManager
for user in usersToEdit:
    un = str(user)
    userOb = dmd.ZenUsers.getUserSettings(str(un))
    for role in roles:
        print 'Adding %s role from %s' % (str(role), str(userOb.id))
        roleManager.assignRoleToPrincipal(str(role), str(userOb.id))