cancel
Showing results for 
Search instead for 
Did you mean: 

Assing an encryption user from a python script

Jump to solution

I'm trying to add an encryprion user to a machine using a python script. Has anybody been able to get this working?

I'm trying :

import mcafee

mc = mcafee.client('EPO','8443','python','python')

mc.eeadmin.assignUser('true','111','CN=johnsmith,OU=home,DC=ABC,DC=com'),'false','ADDOMAIN'

Which just gives me an error:

Traceback (most recent call last):

  File "c:\python\mcafee-samples\test.py", line 23, in <module>

    mc.eeadmin.assignUser('true','111','CN=johnsmith,OU=home,DC=ABC,DC=com')

  File "c:\python\mcafee.py", line 454, in __call__

    raise e

mcafee.CommandInvokerError: Error setting parameters for command: eeadmin.assign User

Thanks

1 Solution

Accepted Solutions
Highlighted
whgibbo
Level 12
Report Inappropriate Content
Message 2 of 3

Re: Assing an encryption user from a python script

Jump to solution

Hi,

Have you looked at the sample supplied with EEPC?

I have included one here :

# 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

epoServerName   = 'epodev2008'
epoServerPort   = '8443'
epoUserName     = 'admin'
epoUserPassword = '12345'
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'

Hope this helps..

# 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

epoServerName   = 'epodev2008'
epoServerPort   = '8443'
epoUserName     = 'admin'
epoUserPassword = '12345'
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'
2 Replies
Highlighted
whgibbo
Level 12
Report Inappropriate Content
Message 2 of 3

Re: Assing an encryption user from a python script

Jump to solution

Hi,

Have you looked at the sample supplied with EEPC?

I have included one here :

# 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

epoServerName   = 'epodev2008'
epoServerPort   = '8443'
epoUserName     = 'admin'
epoUserPassword = '12345'
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'

Hope this helps..

# 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

epoServerName   = 'epodev2008'
epoServerPort   = '8443'
epoUserName     = 'admin'
epoUserPassword = '12345'
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'

Re: Assing an encryption user from a python script

Jump to solution

I did find that.  Thanks.

More McAfee Tools to Help You

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community