2 Replies Latest reply on Nov 16, 2011 12:43 PM by mitch_reid

    Assing an encryption user from a python script

    mitch_reid

      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. Re: Assing an encryption user from a python script
          whgibbo

          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. Re: Assing an encryption user from a python script
            mitch_reid

            I did find that.  Thanks.