Open tionosaja opened 2 years ago
With csv python module you can parse you csv and retrieve the necessary variables. The syntax to create a soap request to create an account is this:
url = 'https://your.server.name:7071/service/admin/soap'
comm = Communication(url)
admin_token = auth.authenticate(
url,
'admin@domain.tld',
'very-secret-password',
admin_auth = True,
)
request = comm.gen_request(token=admin_token)
request.add_request(
'CreateAccountRequest',
{
'name': 'new-account@domain.tld',
'password': 'account-password',
'a': {
'givenName': 'New Account',
'sn': 'Smith',
'displayName': 'New Account Smith'
},
},
'urn:zimbraAdmin'
)
response = comm.send_request(request)
if not response.is_fault():
print (response.get_response())
else:
print(response.get_fault_code())
print(response.get_fault_message())
If you want to do something similar in bash, you could:
while IFS=, read -r account password givenName
do
echo createAccount $account \"$password\" givenName \"$givenName\"
done < file.csv | zmprov -f /dev/stdin
assuming your csv has 3 filelds.
How to create Create multiple user from file.csv using SOAP ?