我们公司连个软件 都不肯花钱买。

用得上硬件防垃圾邮件 羡慕啊。


不过。其实都是用软件做的。只不过。他们的linux是经过定制而已。

首先向大家说一下,我遇到问题时的操作环境
1.sever system:centos 5.5 client system:xp
2.我从原旧有邮件系统导出utf-8格式的csv文件。
首先:我用xp的excel编辑 将没有用的字段删除,改成create_mail_O....py需要的格式,这里我存成acsii码的csv文件。然后再用ultra edit 检查修改。将做好的文件存成utf-8 unix格式 copy到centos 里面
3.运行create_mail....py xxx.csv文件 生成ldif。这时发现首个帐号的信息生成有问题:dn部份mail,mailgroup等部份为乱码。 将第一个帐号信息删除导入后其他 成功。尝试将acsii码的csv文件转换成ldif 再导入,全部不成功。

根据与iredmail核心小组的讨论,认为是我的csv文件有问题。当然他建议我直接 用最原始的文本软件编辑csv文件,我就用了xp 自带的文本工具编辑 ,结果还是一样的。

原本准备放弃了。今天 上午我决定再试一下。
直接在centos的openoffice进行csv文件编辑,可是编辑后的csv文件不知为何每个字段都有"",只好用linux的文本工具将""删除。最后编辑完成 。
使用create_mail_O..py 转换成ldif 。然后通过 php ldap admin 导入 成功!

上面其实是废话。以下是总结的过程
----
create_mail_user_OpenLDAP.py里面
原BASEDN = 'o=domains,dc=iredmail,dc=org'
改成 你的
------
1.linux openoffice 编辑csv文件(格式请参照create_mail..py的提示)
2.用linux自带的文本工具将上面编辑的csv文件里面的""号删除。
3.生成ldif文件
4.通过https://localhost/ldap (phpldapadmin) 导入成功。
------
其实好像也没有找到为何在 xp做csv文件然后转换后不能导入的原因。
我决定试一下生成ascii的csv文件转换后,再通过ldapbrower 导入。
有结果再和大家讨论。

---
最后谢谢开发组对我耐心的指导。ths

确实用英文名字是正确的。
但是 很奇怪的是,中文的csv文件,转换之后,就是第一个帐号的信息出错 后面的不会

解决的笨方法:
首先将csv文件存成utf-8格式 ,然后将其用create_mail_O.....py 转换成ldif文件

这里ldif文件首个帐号的
dn:部份为成dn:: 和一些乱码
mail:也是
storageBaseDirectory:
mailMessageStore:
homeDirectory:
memberOfGroup:
里面的都为乱码
这时候 将首个帐号的上面的乱码部份都改成和第二个帐号一样类型的字符 保存 就可以通过phpldapadmin导入.

虽然说管理员说是我的csv有问题.但是,我还是觉得create...py转换工具 有可能有问题.请检查.

测试之后发现
用windows 自带文件 工具 编辑后的txt 文件存成utf-8格式之后,再用create_mail..py生成ldif文件
这时第一个帐号转换成这样
dn:: bWFpbD1jaGFuZ19wQO+7v2lzY3JlYXRlLmNvbSxvdT1Vc2Vycyxkb21haW5OYW1lPe+7v2l
zY3JlYXRlLmNvbSxvPWRvbWFpbnMsZGM9aXNjcmVhdGUsZGM9Y29t

第二个帐号开始是正确的
dn: mail=guo_jb@kwoks.com,ou=Users,domainName=iscreate.com,o=domains,dc=i
screate,dc=com
---
版主说我的csv文件有问题.

但是,也没有检查出什么问题.
再试

请问是不是删除ldif文件里的changetype: add行,然后再通过phpldapadmin导入

cn这个应该是中文姓名。
你的意思是将ldif里面所有的"changetype: add" 删除是吧。然后尝试导入?

应该能把域名放在后面作为列表可选择就好。

dn: mail=guo_jb@kwoks.cc,ou=Users,domainName=kwoks.cc,o=domains,dc=k
woks,dc=cc

是有空行的。我只是截取了。第一个帐号的内容给你看。

# Prompt to import user data.
'''
Would you like to import them now?""" % (ldif_file)

answer = raw_input('[Y|n] ').lower().strip()

if answer == '' or answer == 'y':
    # Import data.
    conn = ldap.initialize(LDAP_URI)
    conn.set_option(ldap.OPT_PROTOCOL_VERSION, 3)   # Use LDAP v3
    conn.bind_s(BINDDN, BINDPW)
    conn.unbind()
else:
    pass
'''
这一段代码并没有执行。
然后 我用了phpldapadmin导入(ascii生成的ldif)

不能增加该对象到LDAP服务器。
不能增加该对象到LDAP服务器。
LDAP said:    Invalid syntax
Error number:    0x15 (LDAP_INVALID_SYNTAX)
描述:    An invalid attribute value was specified.
warn    LDIF text import
Could not add object mail=chang_p@kwoks.cc,ou=Users,domainName=kwoks.cc,o=domains,dc=kwoks,dc=cc
LDAP said:    Invalid syntax
Error number:    0x15 (LDAP_INVALID_SYNTAX)
描述:    An invalid attribute value was specified.

以下是ascii 格式 csv文件生成的ldif

dn: mail=chang_p@kwoks.cc,ou=Users,domainName=kwoks.cc,o=domains,dc=
kwoks,dc=cc
changetype: add
objectClass: inetOrgPerson
objectClass: mailUser
objectClass: shadowAccount
objectClass: amavisAccount
mail: chang_p@kwoks.cc
userPassword: 19410919cp
mailQuota: 10
cn:: s6PGvA==
sn: chang_p
uid: chang_p
storageBaseDirectory: /var/vmail/vmail01
mailMessageStore: kwoks.cc/c/ch/cha/chang_p-2010.07.29.06.27.26/
homeDirectory: /var/vmail/vmail01/kwoks.cc/c/ch/cha/chang_p-2010.07.29.0
6.27.26/
accountStatus: active
mtaTransport: dovecot
enabledService: mail
enabledService: smtp
enabledService: pop3
enabledService: pop3secured
enabledService: imap
enabledService: imapsecured
enabledService: deliver
enabledService: forward
enabledService: senderbcc
enabledService: recipientbcc
enabledService: managesieve
enabledService: internal
enabledService: managesievesecured
enabledService: shadowaddress
enabledService: displayedInGlobalAddressBook
memberOfGroup: all@kwoks.cc
memberOfGroup: gad_all@kwoks.cc

以下是 utf-8 格式 csv文件生成的ldif 文件其中一个帐号的内容

dn:: bWFpbD1jaGFuZ19wQO+7v2lzY3JlYXRlLmNvbSxvdT1Vc2Vycyxkb21haW5OYW1lPe+7v2l
zY3JlYXRlLmNvbSxvPWRvbWFpbnMsZGM9aXNjcmVhdGUsZGM9Y29t
changetype: add
objectClass: inetOrgPerson
objectClass: mailUser
objectClass: shadowAccount
objectClass: amavisAccount
mail:: Y2hhbmdfcEDvu79pc2NyZWF0ZS5jb20=
userPassword: 19410919cp
mailQuota: 10
cn:: 5bi46JCN
sn: chang_p
uid: chang_p
storageBaseDirectory: /var/vmail/vmail01
mailMessageStore:: 77u/aXNjcmVhdGUuY29tL2MvY2gvY2hhL2NoYW5nX3AtMjAxMC4wNy4yO
S4wMS41NS40Ni8=
homeDirectory:: L3Zhci92bWFpbC92bWFpbDAxL++7v2lzY3JlYXRlLmNvbS9jL2NoL2NoYS9j
aGFuZ19wLTIwMTAuMDcuMjkuMDEuNTUuNDYv
accountStatus: active
mtaTransport: dovecot
enabledService: mail
enabledService: smtp
enabledService: pop3
enabledService: pop3secured
enabledService: imap
enabledService: imapsecured
enabledService: deliver
enabledService: forward
enabledService: senderbcc
enabledService: recipientbcc
enabledService: managesieve
enabledService: internal
enabledService: managesievesecured
enabledService: shadowaddress
enabledService: displayedInGlobalAddressBook
memberOfGroup:: YWxsQO+7v2lzY3JlYXRlLmNvbQ==
memberOfGroup:: Z2FkX2FsbEDvu79pc2NyZWF0ZS5jb20=

csv格式如下
kwoks.cc,chang_p,78976734,常平,10,all:gad_all

使用python create_mail_user_OpenLDAP.py  aaa.csv 后生成aaa.ldif文件然后通过my ldap server导入报错 导入不成功。

生成ldif 文件之后,如何导入啊。

我只是想增加用户的其他信息.并不是为maillist增加部门属性.

不好意思.
之前我请教过,为何没有" 部门 " 这一属性,你说maillist 就算是部门.

其实maillist不能算是部门
因为一个人有可能属于多个maillist,但是部门应该是唯一的.
新版能增加 用户的其他信息如:部门等 的意思,

能否 在新增用户里面增加user id 可选的输入呢.
还有maillist和用户的部门标识并不是一定相同的.()
新版的能否加一些用户的其他信息项呢
如:部门等 .

你好,同时问一下用户 id 的作用是用来做什么的。

还需要改create_mail_user_OpenLDAP.py里面吗

# ------------------------- SETTINGS -------------------------------
# LDAP server address.
LDAP_URI = 'ldap://127.0.0.1:389'

# LDAP base dn.
BASEDN = 'o=domains,dc=iredmail,dc=org'

# LDAP bind dn & password.
#BINDDN = 'cn=Manager,dc=iredmail,dc=org'
BINDDN = 'cn=vmailadmin,dc=iredmail,dc=org'
BINDPW = 'passwd'

# Storage base directory.
STORAGE_BASE_DIRECTORY = '/var/vmail/vmail01'

# Hashed maildir: True, False.
# Example:
#   domain: domain.ltd,
#   user:   zhang (zhang@domain.ltd)
#
#       - hashed: d/do/domain.ltd/z/zh/zha/zhang/
#       - normal: domain.ltd/zhang/
HASHED_MAILDIR = True
# --------------------------------------------------------------

有什么办法吗

系统 centos 5.4 32bit
安装到 easy_install web.py Jinja2 python-ldap==2.3.11 n 这一步时下面是终端提示的信息
有几行是提否出错的。请问如何解决?是否不影响?
[root@mail openldap]# easy_install web.py Jinja2 python-ldap==2.3.11 netifaces
Searching for web.py
Reading http://cheeseshop.python.org/pypi/web.py/
Reading http://webpy.org/
Reading http://cheeseshop.python.org/pypi/web.py/0.34
Best match: web.py 0.34
Downloading http://webpy.org/static/web.py-0.34.tar.gz
Processing web.py-0.34.tar.gz
Running web.py-0.34/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9k_-bl/web.py-0.34/egg-dist-tmp-oTlZfr
zip_safe flag not set; analyzing archive contents...
web.application: module references __file__
web.debugerror: module references __file__
Adding web.py 0.34 to easy-install.pth file

Installed /usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg
Processing dependencies for web.py
Searching for Jinja2
Best match: Jinja2 2.2.1
Adding Jinja2 2.2.1 to easy-install.pth file

Using /usr/lib/python2.4/site-packages
Processing dependencies for Jinja2
Searching for python-ldap==2.3.11
Reading http://cheeseshop.python.org/pypi/python-ldap/
Reading http://www.python-ldap.org/
Reading http://cheeseshop.python.org/pypi/python-ldap/2.3.11
Best match: python-ldap 2.3.11
Downloading http://pypi.python.org/packages/source/ … 0a7f9b42ed
Processing python-ldap-2.3.11.tar.gz
Running python-ldap-2.3.11/setup.py -q bdist_egg --dist-dir /tmp/easy_install-JsDS4V/python-ldap-2.3.11/egg-dist-tmp-kVUn2O
extra_compile_args:
extra_objects:
include_dirs: /opt/openldap-RE24/include /usr/include/sasl
library_dirs: /opt/openldap-RE24/lib
libs: ldap_r lber sasl2 ssl crypto
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
warning: no files found matching 'Makefile'
warning: no files found matching 'Modules/LICENSE'
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
file Lib/ldap.py (for module ldap) not found
file Lib/ldap/schema.py (for module ldap.schema) not found
Adding python-ldap 2.3.11 to easy-install.pth file

Installed /usr/lib/python2.4/site-packages/python_ldap-2.3.11-py2.4-linux-i686.egg
Processing dependencies for python-ldap==2.3.11
Searching for netifaces
Reading http://cheeseshop.python.org/pypi/netifaces/
Reading http://alastairs-place.net/netifaces
Reading http://cheeseshop.python.org/pypi/netifaces/0.5
Best match: netifaces 0.5
Downloading http://alastairs-place.net/2007/03/neti … 0.5.tar.gz
Processing netifaces-0.5.tar.gz
Running netifaces-0.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-21ZDgN/netifaces-0.5/egg-dist-tmp-IQaF6Q
checking for getifaddrs... found.
checking for getnameinfo... found.
checking for optional header files... netash/ash.h netatalk/at.h netax25/ax25.h neteconet/ec.h netipx/ipx.h netpacket/packet.h linux/llc.h linux/tipc.h.
checking whether struct sockaddr has a length field... no.
checking which sockaddr_xxx structs are defined... at ax25 in in6 ipx un ash ec ll llc.
zip_safe flag not set; analyzing archive contents...
Adding netifaces 0.5 to easy-install.pth file

Installed /usr/lib/python2.4/site-packages/netifaces-0.5-py2.4-linux-i686.egg
Processing dependencies for netifaces