Topic: Creating a new account using Java
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.9
- Deployed with iRedMail Easy or the downloadable installer? downloadable
- Linux/BSD distribution name and version: Centos 7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
I'm attempting to create a new e-mail user using Java. I'm accessing /iredadmin/api/login and receiving the "iRedAdmin-Pro-ldap" cookie containing the session id and a 200 return status. When I attempt to create a user accessing /iredadmin/api/user/<email> I receive a status of 200, but no user appears in iRedAdminPro.
Is there a log which would provide me with additional details on what is going wrong?
I'm using Apache HttpComponents 4.5 (https://hc.apache.org) and the following code:
CloseableHttpClient iRed = HttpClients.createDefault();
HttpPost iRedPost = new HttpPost("https://(server)/iredadmin/api/login");
List<NameValuePair> postData = new ArrayList<NameValuePair>();
postData.add(new BasicNameValuePair("username","(postmaster account)"));
postData.add(new BasicNameValuePair("password","(postmaster password)"));
iRedPost.setEntity(new UrlEncodedFormEntity(postData));
CloseableHttpResponse response = iRed.execute(iRedPost);
System.out.println("Login status: " + response.getStatusLine().getStatusCode());
Header[] headers = response.getHeaders("Set-Cookie");
for (Header h : headers) {
System.out.println(h.getValue().toString());
}
iRedPost = new HttpPost("https://(server)/iredadmin/api/user/(new e-mail address)");
postData = new ArrayList<NameValuePair>();
postData.add(new BasicNameValuePair("cn","Test Account"));
postData.add(new BasicNameValuePair("password","(new password)"));
postData.add(new BasicNameValuePair("mailQuota","4096"));
iRedPost.setEntity(new UrlEncodedFormEntity(postData));
System.out.println("Create user status: " + response.getStatusLine().getStatusCode());
Thanks,
Bob
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.