Hi Everybody:
I need to add a lot of users to an LDAP system for testing and I would like to do it in batch mode. For my small tests have been doing something like this: #!/bin/bash # Script to create a new user. ipa user-add bigbob \ --email=b...@bigbobsemporium.com \ --first=Bob \ --last=Bigg \ --password \ --setattr=description='The sales guy.' <<-EOF b1gB0bsTmpPwd b1gB0bsTmpPwd EOF However, I am python guy and would like to use it instead. I am sure that I can do a similar thing using pexpect in python. Probably something like this: # This code has not been tested. It is only for a thought experiment. # Add a user and enter the password using pexpect. cmd = "ipa user-add bigbob --email='bbob@BigBobsEmporium." cmd += " --first=Bob --last=Bigg --password " cmd += "--setattr=description='The sales guy.'" rets = ['Password', 'Enter Password again to verify', pexpect.EOF, pexpect.TIMEOUT] c = pexpect.spawn(cmd,timeout=None) i = c.expect(rets) if i == 0: # Password child.sendline('b1gB0bsTmpPwd') i = c.expect(rets) if i == 1: # Enter Password again to verify child.sendline('b1gB0bsTmpPwd') i = c.expect(rets) if i == 2: print 'SUCCESS' else: sys.exit('ERROR: something bad happened #1') else: sys.exit('ERROR: something bad happened #2') else: sys.exit('ERROR: something bad happened #3') But I was wondering whether there was a better using the IPA API. Is there a way for me to do that? Any help or insights would be greatly appreciated. Thanks, Joe
_______________________________________________ Freeipa-users mailing list Freeipa-users@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-users