Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

# Copyright (C) 2011 McAfee, Inc. All Rights Reserved.

# -*- coding: utf-8 -*-


#
# This is a sample script that demonstrates assigning a user to a single system
# where the LDAP Server is automatically detected.

import sys
import mcafee

############SERVER CONFIGURATIONS###############################
epoServerName = 'vmsdapoe300a.amr.corp.intel.com'
epoServerPort = '8445'
epoUserName = 'admin'
epoUserPassword = 'Int3lePO!' ###MISSING TO HIDE THE PASSWORD
#######################################

dnToAssign = 'CN=mike_1,CN=Users,dc=epotest,dc=net'
computerName = 'vmxp-gibson1'

print 'Attempting connection to ePO Server.'


#initiate connection
mc = mcafee.client(epoServerName, epoServerPort, epoUserName, epoUserPassword)

# Attempt to locate the computerId to assign the user to.


print 'Attempting to obtaining Computer ID for ['+computerName+']'
computer = mc.system.find(computerName);
if len(computer) == 0:
print 'Failed to find the computer id'
sys.exit()
if len(computer) != 1:
print 'More than 2 computers found, script was designed to work with one
computer only'
sys.exit()
computerId = computer[0].get('EPOComputerProperties.ParentID')

# If you wish to list the current user assignments uncomment the following line,
which includes the users assigned via LDAP groups/ous
#print mc.core.executeQuery(target="EPESystemUsers", where='(where ( eq
EPOLeafNode.NodeName "%s" ))' % computerName)

result = mc.eeadmin.assignUser(systemNode='True', nodeId='%d' % computerId, dn='%s'


% dnToAssign)
print result
if result != 'Succeeded':
print 'Failed to assign the item';
sys.exit()

# If you wish to list the current user assignments uncomment the following line,
which includes the users assigned via LDAP groups/ous
#print mc.core.executeQuery(target="EPESystemUsers", where='(where ( eq
EPOLeafNode.NodeName "%s" ))' % computerName)
print 'Finished'

You might also like