<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[iRedMail — Get list of all users/emails, for every domain]]></title>
	<link rel="self" href="http://www.iredmail.org/forum/feed-atom-topic4318.xml" />
	<updated>2013-01-02T11:10:56Z</updated>
	<generator>PunBB</generator>
	<id>http://www.iredmail.org/forum/topic4318-get-list-of-all-usersemails-for-every-domain.html</id>
		<entry>
			<title type="html"><![CDATA[Re: Get list of all users/emails, for every domain]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19722.html#p19722" />
			<content type="html"><![CDATA[<p>Thank you but I dont have any knowledge of working with ldap so the &quot;ldapsearch&quot; hasn&#039;t helped. </p><p>I was able to simplify one of your examples so this 90% achieves what I need. </p><p>Although I find this is also listing the domain names. </p><div class="codebox"><pre><code>#!/usr/bin/env python
# encoding: utf-8

import sys
import ldap

# Note:
#   * bind_dn must have write privilege on LDAP server.
uri = &#039;ldap://127.0.0.1:389&#039;
basedn = &#039;o=domains,dc=example,dc=com&#039;
bind_dn = &#039;cn=Manager,dc=example,dc=com&#039;
bind_pw = &#039;pass&#039;

# Initialize LDAP connection.
conn = ldap.initialize(uri=uri, trace_level=0,)
conn.bind_s(bind_dn, bind_pw)

# Get all mail users.
allUsers = conn.search_s(
        basedn,
        ldap.SCOPE_SUBTREE,
        &quot;(objectClass=mailUser)&quot;,
        [&#039;mail&#039;],
        )

# Print all email users separated by comma
for user in allUsers:
    (dn, entry) = user
    mail = entry[&#039;mail&#039;][0]
    
    if len(mail) &gt; 0:    
        print &gt;&gt; sys.stdout, &quot;%s, &quot; %(mail)

# Unbind connection.
conn.unbind()</code></pre></div>]]></content>
			<author>
				<name><![CDATA[web2works]]></name>
				<uri>http://www.iredmail.org/forum/user2175.html</uri>
			</author>
			<updated>2013-01-02T11:10:56Z</updated>
			<id>http://www.iredmail.org/forum/post19722.html#p19722</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Get list of all users/emails, for every domain]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19706.html#p19706" />
			<content type="html"><![CDATA[<p>You can get all mail users/lists with command &quot;ldapsearch&quot;. <img src="http://www.iredmail.org/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[ZhangHuangbin]]></name>
				<uri>http://www.iredmail.org/forum/user2.html</uri>
			</author>
			<updated>2013-01-01T03:23:31Z</updated>
			<id>http://www.iredmail.org/forum/post19706.html#p19706</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Get list of all users/emails, for every domain]]></title>
			<link rel="alternate" href="http://www.iredmail.org/forum/post19705.html#p19705" />
			<content type="html"><![CDATA[<p>Is it possible to run a quick scripts which gets a list of all the email addresses for every domain? </p><p>I want to send out a mass email using bcc letting all the users know of any changes, so ideally this list would be separated by comma. </p><p>==== Required information ====<br />- iRedMail version: 0.8.3 LDAP<br />====</p>]]></content>
			<author>
				<name><![CDATA[web2works]]></name>
				<uri>http://www.iredmail.org/forum/user2175.html</uri>
			</author>
			<updated>2012-12-31T14:13:55Z</updated>
			<id>http://www.iredmail.org/forum/post19705.html#p19705</id>
		</entry>
</feed>
