cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

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
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'

View solution in original post

2 Replies
Highlighted
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'

View solution in original post

Highlighted

Re: Assing an encryption user from a python script

Jump to solution

I did find that.  Thanks.

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

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