Author Topic: How to setup DocMGR and integrate with Zentyal 2.2 LDAP  (Read 5686 times)

Barrydocks

  • Zen Warrior
  • ***
  • Posts: 145
  • Karma: +4/-0
    • View Profile
How to setup DocMGR and integrate with Zentyal 2.2 LDAP
« on: March 01, 2013, 10:03:33 pm »
DocMGR is a simple document management system that allows version control, full text indexing of documents and integration with Zentyal mail system and LDAP user database.  It is easily installed on ubuntu with apache and php.  For more details see www.docmgr.org

This assumes you have successfully installed Ubuntu 10.04, Zentyal 2,2 and setup the users and groups module
Enable the webserver module in the Zentyal interface
Enable SSL if you want a https connection (probably advisable if the site is accessible by the rest of the world).
Ensure the correct ports are open on the firewall (usually port 80 and 443 - you will need to change the Zentyal admin port to something other than 443)
You will probably also have to set up the Zentyal CA certificates as well

To force an ssl conection to your domain:
Log in as root
Create a hook to adjust the webserver configuration:
Code: [Select]
nano /etc/zentyal/hooks/webserver.postsetconf
Paste the following:
Code: [Select]
#!/bin/sh

sed '/<VirtualHost \*:80>/r /etc/apache2/apache_mod.txt' /etc/apache2/sites-available/default > /etc/apache2/sites-available/default.tmp
mv /etc/apache2/sites-available/default.tmp /etc/apache2/sites-available/default

Save the file > ctrl + x
make the webserver.postsetconf executable:
Code: [Select]
chmod +x /etc/zentyal/hooks/webserver.postsetconf
Create the apache_mod.txt file:
Code: [Select]
nano /etc/apache2/apache_mod.txt
Paste the following:
Code: [Select]
# redirect http to https
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

Make sure the apache rewrite rule is installed and enabled:
Code: [Select]
a2enmod rewrite
Restart Zentyal webserver module:
Code: [Select]
/etc/init.d/zentyal apache restart
Now browse to http://yourserver.yourdomain and you will find it redirects you to https://yourserver.yourdomain

Download the latest version of DocMGR which was 1.2.6 at the time of writting:
Code: [Select]
wget https://downloads.sourceforge.net/project/docmgr/docmgr/1.2.6/docmgr-1.2.6.tar.gz
Untar the file:
Code: [Select]
tar xvf doc*
If you are just accessing DocMGR from your internal LAN then move the files to the webserver root directory:
Code: [Select]
mv docmgr /var/www/
Set the permissions correctly:
Code: [Select]
chown -R www-data:www-data /var/www/docmgr
If you are allowing access from the 'ternet, then you might want to put the DocMGR files somewhere else and create an alias in apache:
Code: [Select]
mv docmgr /usr/share/Set the file preferences as above.

Then setup the apache site:
Code: [Select]
nano /etc/apache2/sites-available/docmgrPaste the following:
Code: [Select]
Alias /docmgr "/usr/share/docmgr"

<Directory /usr/share/docmgr/>
    DirectoryIndex index.php
    Options -Indexes +FollowSymLinks
    AllowOverride Options

    Order allow,deny
    Allow from all
</Directory>
Enable the site and reload apache:
Code: [Select]
a2ensite docmgr && /etc/init.d/apache2 reload
Install a few other items that are required:
Code: [Select]
apt-get install php5 php5-cli php5-pgsql php5-ldap python-uno ocrad xpdf imagemagick zip libtiff-tools openoffice.org-core php5-pgsql openoffice.org-writer openoffice.org-calc openoffice.org-draw openoffice.org-impress openoffice.org-java-common openoffice.org-headless python-openoffice
You now need to setup the database, I tend to use webmin for this sort of thing.  Download the current version of webmin:
Code: [Select]
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.620_all.deb
Install some stuff that webmin depends on:
Code: [Select]
apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
Install webmin:
Code: [Select]
dpkg --install webmin_1.620_all.deb
Now browse to:
https://yourserver.yourdomain:10000

Log in with the user you used to setup Ubuntu with.
Goto Servers > ProgresSQL Database Server > ProgresSQL Users
Create a user with a password, ensure the Can create databases and can create users options are selected.
Create a new database for DocMGR, select your new user as the owner

Now browse to:
https://yourserver.yourdomain/docmgr
Follow the install instructions using the database name, user and password you created. 
If the database and the webserver are on the same machine as zentyal then set the url for the database to localhost
For the external applications make sure the following paths are used:

Path to python binary with UNO bindings (usually in OpenOffice program directory)
/usr/lib/openoffice/program

Path to sendmail
/usr/lib/sendmail

PHP CLI binary
/usr/bin/php

Go back to your terminal window.
enter the docmgr directory:
Code: [Select]
cd /var/www/docmgr
remove the install files:
Code: [Select]
rm -r install
remove the scripts files
Code: [Select]
rm -r scripts
I would suggest moving the files directory some where else:
Code: [Select]
mv files /media/files
Now set up the basic DocMGR configuration:
Code: [Select]
nano config/config.php
Find the following lines:
Code: [Select]
//Absolute path to DocMGR files directory
define("FILE_DIR",SITE_PATH."/files");
Change to:
Code: [Select]
//Absolute path to DocMGR files directory
//define("FILE_DIR",SITE_PATH."/files");
define("FILE_DIR","/media/files");

Find the following lines:
Code: [Select]
//Enable LDAP for accounts
//define("USE_LDAP","1");
Change to:
Code: [Select]
//Enable LDAP for accounts
define("USE_LDAP","1");


Now set up the LDAP integration, you will need the information form the LDAP set up on the Users & Groups module in the Zentyal interface.  Make sure you adjust the password conception form MD5 to SHA.  Edit the ldap-config.php file,
Code: [Select]
nano config/ldap-config.phpto look like this:
Code: [Select]
//your ldap server uri
define("LDAP_SERVER","ldap://localhost");

//your ldap server port
define("LDAP_PORT","389");

//the dn to bind to your server with
define("BIND_DN","cn=ebox,dc=yourserver,dc=yourdomain.com,dc=com");

//the password of the above specified dn
define("BIND_PASSWORD","scerete");

//your search attribute base for accounts
define("LDAP_BASE","ou=Users,dc=yourserver,dc=yourdomain,dc=com");

//default base for creating accounts
define("LDAP_CREATE_BASE",LDAP_BASE);

//a search filter to limit valid accounts to
define("LDAP_FILTER","(uid=*)");

//password encrytion in database
define("LDAP_CRYPT","SHA");

//ldap protocol
define("LDAP_PROTOCOL","3");

//default group id for a new account
define("DEFAULT_GID","100");

//base of our tree
define("LDAP_ROOT","dc=yourserver,dc=yourdomain,dc=com");

Now you need to adjust the account.php file to use the correct password encryption:
Code: [Select]
nano lib/account/ldap.phpYou will need to find MD5 and replace with SHA and find md5 and replace with sha1 (note the case)
To enable user searches to work correctly (allows sharing of documents) fin this line:
Code: [Select]
return $ret;and add this line directly before it:
Code: [Select]
$ret["count"]=$num;
To allow users with IE and MS office installed to edit files directly in ther browser you will need WebbOffice ActiveX control, download it to the correct directory, then rename it and set the permissions:
Code: [Select]
cd controls
wget http://www.dianju.cn/p/weboffice/html/weboffice_v6.0.5.0.cab
mv weboffice_v6.0.5.0.cab weboffice.cab
chown www-data:www-data weboffice.cab

Now add a LDAP user as DocMGR admin.  Go back to webmin and select you docmgr database which will now contain tables etc, select Execute SQL, paste the following:
Code: [Select]
INSERT INTO auth.accountperm (account_id,bitset,enable,bitmask) VALUES ('2001','1','t','00000000000000000000000000000001');where 2001 is the uid of the user you want to use, generally speaking Zentyal creates the uid in order of user creation so 2001 will be the first user you created, 2002 the second and so forth.

Finally, set the user to be used for indexing otherwise it won't work - this needs to be the same uid as the admin user:
Code: [Select]
nano bin/docmgr-indexer.php
Find these lines at the top:
Code: [Select]
//set which DocMGR user id the script should run as.  defaults to
//"admin" user
define("USER_ID","1");
Change to:
Code: [Select]
//set which DocMGR user id the script should run as.  defaults to
//"admin" user
//define("USER_ID","1");
define("USER_ID","2001");
You will also need to comment out these 2 lines in order to make the indexing work correctly as the ldap user:
Code: [Select]
$a = new AUTH($info["login"],$info["password"]);
if ($a->getError()) die($a->getError()."\n");

Now login to DocMGR and have fun!!

To reindex all the documents in the library just use this command:
Code: [Select]
php bin/docmgr-indexer.php --reindex-all
Other things:
You could make the import directory a samba share in zentyal, but I am not sure what permissions are needed.  Similarly you could create a symlink to the users home directory and the DocMGR users directory, I expect there could be an elegant method of doing this automgically with php and variable such as $HOME etc?

This worked for me but I can't guarantee it will work for you, I am not an IT professional so I am more than happy if you spot any glaring errors or omissions  :)
DO NOT BE TEMPED TO ADMISITETER YOUR LDAP USERS OR GROUPS FROM THE DOCMGR INTERFACE - IT WILL BE BAD - YOU HAVE BEEN WARNED  :o

« Last Edit: March 09, 2013, 10:45:05 pm by Barrydocks »

ichat

  • Zen Hero
  • *****
  • Posts: 795
  • Karma: +28/-16
  • RTFM!
    • View Profile
Re: How to setup DocMGR and integrate with Zentyal 2.2 LDAP
« Reply #1 on: March 01, 2013, 11:58:00 pm »
really apreciate that you have givven your discoveries back to the forum,


getting help is one thing,  actually giving it back  is another...   


so once again,  thank you for  being the good example... 

1+ karma well earned.
All tips hints and advices are based on my personal experience.
As I try my best to be as accurate as possible, following my advice is always at your own risk,
I claim absolutely NO responsibility in any way!

Barrydocks

  • Zen Warrior
  • ***
  • Posts: 145
  • Karma: +4/-0
    • View Profile
Re: How to setup DocMGR and integrate with Zentyal 2.2 LDAP
« Reply #2 on: March 02, 2013, 06:03:36 pm »
Just corrected a few errors and typos :)

It's really for my benefit, not being an IT pro I don't do these things too often and I tend to forget the finer details which is slightly frustrating  :(

really apreciate that you have givven your discoveries back to the forum,


getting help is one thing,  actually giving it back  is another...   
anyway isn't that the idea of a community??