Home php教程 php手册 ldap+qmail+postaci 安装, 用户管理

ldap+qmail+postaci 安装, 用户管理

Jun 21, 2016 am 09:10 AM
ldap nbsp quot var

用户管理

ldap+qmail+postaci  安装, 用户管理

参考文献:
1. 建一个大容量的webmail系统(作者:谢顺华)
    目前唯一能找到的中文qmail+ldap资料
    http://www.linuxforum.net/doc/webmail.html
2. Postaci Webmail
    基于php的webmail系统, 支持pop3, imap, 使用数据库做缓存.
    相对于imp和sqwebmail来说, 配置相当容易, 而且界面很好.
    (http://www.trlinux.com/)
3. Simple ldap user admin tool
    For Qmail的php版用户管理, 可以设置用户资料, 别名, maillist, 公司组织...
    http://sourceforge.net/projects/alldap/
4. Softerra LDAP Browser
    win32的ldap查看修改工具
    http://www.ldapbrowser.com
5. Life With qmail-ldap
    http://www.lifewithqmail.org/ldap/
6. Life With qmail
    http://www.lifewithqmail.org/


说明:
    考虑到qmail使用系统用户在管理上不大方便. 而使用mysql作为用户又会和mysql用户冲突, 而且mysql的局限性很大, 没有ldap的open和自由扩展特性. 使用ldap后, 利用php的ldap函数就可以实现用户管理, 用户可方便的自行编程解决用户管理.
    因为不是虚拟主机, 所以选用了配置简单, 好用的Postaci和Simple ldap user admin tool. 适合单一团体/公司使用.



安装:

1. openldap请参考文献1的步骤1.在/etc/openldap目录下是openldap的设置, 除了要按参考1中增加qmail的qmailUser类型外, 还要注意修改slapd.conf文件, 关键内容如下:

#你的公司名, 最好用站点名
suffix          "dc=test, dc=com"
#管理员名称, 类似于系统管理员. 很长, 但是很重要.
rootdn          "cn=Manager, dc=test, dc=com"
#管理员密码(这里用的是明文密码)
rootpw          secret
加入基本数据:
ldapadd -D "cn=Manager,dc=test, dc=com" -W

dn: dc=test, dc=com
objectclass: dcObject
objectclass: organization
o: test Company
dc: test


dn: cn=Manager, dc=test, dc=com
objectclass: organizationalRole
cn: Manager


2. qmail需要加for ldap的补丁, 并且配置pop3, imap, sendmail.请参考文献1中的步骤2. 其中注意以下事项:

ldap要求qmail使用Maildir格式, 所以, 要修改/var/qmail/rc如下:    

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "`cat /var/qmail/control/defaultdelivery`" splogger qmail

在/var/qmail/control/defaultdelivery中内容如下:

./Maildir/

/var/qmail/control/ldapuid和ldapgid是ldap用户资料中的qmailUid/qmailGid的缺省值, 设置后ldap中可不必设置. 注意此处uid和gid必是存放mail目录的uid/gid, 一般是/mail, 属性是750, 不可对其它人可写, 否则出错. 考虑到要在php中执行管理用户的操作, 所以这个uid/gid和apache的相同, 可以在apache/conf/httpd.conf中修改. 注意虚拟主机时可能会有安全问题.

用tail -n 30 /var/log/maillog可以查看发送mail的过程记录, 错误会被记录在内, qmail出错时会自动回信给发件人, 不加-n 30只会看到自动回信的正确信息!

RedHat7中使用xinetd, 不同于老版的inetd, 配置文件放在/etc/xinetd.d/下, 修改如下:

pop3文件:

#default: off
# description: The POP3 service allows remote users to access their mail \
#              using an POP3 client such as Netscape Communicator, mutt, \
#              or fetchmail.
service pop3
{
        socket_type             = stream
        protocol                = tcp
        wait                    = no
        user                    = root
        server                  = /var/qmail/bin/qmail-popup
        server_args             = test.com /var/qmail/bin/auth_pop /var/qmail/bin/qmail-pop3d Maildir
        only_from               = 0.0.0.0
        log_type                = FILE /var/log/maillog
        disable                 = no

        log_type                = FILE /var/log/xinetd.log  
        log_on_success          = HOST
        log_on_failure          = HOST RECORD
}

smtp文件:
# default: off
# description: The POP3 service allows remote users to access their mail \
#              using an POP3 client such as Netscape Communicator, mutt, \
#              or fetchmail.
service smtp
{
        socket_type             = stream
        protocol                = tcp
        wait                    = no
        user                    = qmaild
        server                  = /var/qmail/bin/tcp-env
        server_args             = -R /var/qmail/bin/qmail-smtpd
        log_type                = FILE /var/log/maillog
        env                     = NODNSCHECK=""
        log_on_success          = HOST
        log_on_failure          = HOST RECORD
        only_from               = 0.0.0.0
        disable                 = no
}
如果有其它pop3, smtp的服务应该设定其disable项为yes, 以免冲突.

/var/qmail/control/下的控制文件可以参考文献1的步骤5,一般需要以下文件:
ldapbasedn,ldaplogin,ldappassword,ldapuid,ldapgid,ldapserver

3. 安装php版ldap用户管理工具.(参考文献3)
主要配置都在common.inc文件里面, 如果你的php系统没有对.inc文件处理, 会暴露出系统配置, 建议修改成
common.inc.php, 然后分别修改index.php和format.php的第二行. common.inc.php主要修改如下: 也可以参考postaci的安装文件:

//刚开始的时候可能问题很多, 建议设置成1, 以便观察错误在哪里.
$debug = 0;
//这里有些地方可能适合虚拟主机情况, 这里没用到, 待研究

$root_dn = "dc=test, dc=com";
$exchanges_dn = "".$root_dn;    
$people_dn = "".$root_dn;
$lists_dn = "".$root_dn;

//这里要注意和步骤1中设置一致
$ldap_host = "localhost";
$bind_dn = "cn=Manager, dc=test, dc=com";
$pw = "secret";
$mainTitle = "LDAP user admin";

//这里要和步骤2中设置一致
$qmailuid = 501;        
$qmailgid = 501;
$messageStoreDir = "/mail";

$mailQuota = "10000000000S,100000C";
$generalUser = "steeven";

/* not sure on the relevance of this... */
$mailHost = "test.com";

//你的公司部门, 可增减, 自己汉化吧 :)
$org_units = array( "Routed", "Switched", "Colocation", "Networks", "Metro", "Recruitment", "Commercial", "Finance", "IT", "Marketing" );

$acc_status = array( "active", "nopop", "disabled" );
$default_email = "test.com";
$logoImg = "../poweredby.png";
$ver = "0.03";

这个老外写的管理工具很好用, 可以设置转发mail, 无限mail别名; 按地域划分公司组织, 下面又分部门, 每个部门又可以指定邮件, 发给部门的邮件可以指定哪些人来接受. 也可以自定义一些maillist, 管理参加人员. 充分体现了ldap的灵活性. 难怪notes, windows都向ldap靠拢 :)

如果qmail没有设置成自动创建用户目录, 可以在add.php第188行增加如下代码:
                if (!is_dir($messageStoreDir."/".$uid[0])){
                        mkdir($messageStoreDir."/".$uid[0],0770);
                }
                if (!is_dir($messageStoreDir."/".$uid[0]."/".$uid)){
                        mkdir($messageStoreDir."/".$uid[0]."/".$uid,0770);
                }

在add.php中增加用户时的LoginId似乎也有点问题, 可直接采用firstName:
            function create_username() {
                var first_str = document.user_details.elements[2].value;
                document.user_details.elements[11].value = first_str.toLowerCase();
            }

利用参考文献4中的LdapBrowser可以看到对LDAP的相关修改, 或者手动修改.

4. 安装Postaci, webmail(参考文献2).
这是一个基于php的webmail, 具有比较完善的功能, 而且支持imap, pop3. 需要mysql支持. 用户可以自行汉化, 文件在lang目录下.
解压后修改includes目录下global.inc文件(有安全顾虑, 参考步骤3), 里面有配置说明.
Following doc/INSTALL to install

安装完成后添加适当用户, 然后就可以通过becky, outlook, foxmail....等收发邮件. 用浏览器打开postaci的安装目录就可以通过web收发mail了.



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

How to Fix Activation Error Code 0xc004f069 in Windows Server How to Fix Activation Error Code 0xc004f069 in Windows Server Jul 22, 2023 am 09:49 AM

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using

See all articles