Knowledgetree Document Management System on a WHS

I setup Knowledgetree on my WHS because I didn’t like other options and it was free. I didnt want to use the canned installation because I didn’t want Apache and openoffice running in the background taking up my ram.

KT = Knowledgetree
WHS = Windows Home Server

  1. Setup a shared directory for kt with duplication, in my example I am going to use DMS you can use DMS$ if you want it hidden from browsing
    1. Add the users that are going to use KT
  2. Install the WHS PHP Extension
  3. Install WHS MySql Extension
    2. Change your mysql root password at http://localhost/pma
  4. Enable curl in php.ini
    1. Edit c:\php5\php.ini and add extension=php_curl.dll under the other extensions
  5. Install SUN Java 1.6
  6. Download the KT Source Code its about 60mb, the Windows version.
  7. Extract KT to d:\dms
    1. Add full rights for the “Windows Home Server Users” group to d:\dms
  8. Create a virtual directory under the default website in IIS called DMS and using d:\dms as the document root
    1. Disable anonymous authentication and enabled basic authentication
  9. Run the KT setup at http://localhost/dms
  10. Setup the httpsso for single sign-on to your whs users.
    2. you must first manually make the matching user in KT first.
  11.  Scheduled Tasks 
    1.  ktscheduler – runs internal tasks
      1. Run: c:\php5\php.exe d:\dms\bin\scheduler.php
      2. Start in: d:\dms\bin
      4. Run every 15 minutes for 24 hours
    2. ktlucene
      1. Run: “C:\Program Files\Java\jre6\bin\java.exe” -jar D:\DMS\bin\luceneserver\ktlucene.jar
      2. Start in: D:\DMS\bin\luceneserver
      4. Run at system startup
      5. Uncheck the stop the task if it runs for 72 hours
    3. ktDbBackup
      1. Run: C:\php5\php.exe d:\dms\ktdbbackup.php
      2. Start In: d:\dms
      3. Run As: Administrator (needs network access for backups)
      4. Run every 12 hours for 24 hours

    #kt backup for whs
    #dump sql backup of kt to document root
    #dump a quick csv to help convert files back to their original names
    $ktconfig = parse_ini_file("config/config.ini");
    $mysqlLink = mysql_connect($ktconfig["dbHost"],$ktconfig["dbUser"],$ktconfig["dbPass"]);
    if (!$mysqlLink) {
        echo "Unable to connect to DB: " . mysql_error();
    if (!mysql_select_db($ktconfig["dbName"])) {
        echo "Unable to select mydbname: " . mysql_error();
    #get document location from db
    $sql = 'SELECT * FROM `config_settings` WHERE item = \'documentRoot\'';
    $result = mysql_query($sql);
    if (!$result) {
        echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    if (mysql_num_rows($result) == 0) {
        echo "No rows found, nothing to print so am exiting";
    $row = mysql_fetch_assoc($result);
    $docHome = $row["value"];
    #dump database to document root
    system('mysqldump --user ' . $ktconfig["dbAdminUser"] . ' --password=' . $ktconfig["dbAdminPass"] . ' ' . $ktconfig["dbName"] . ' >' . $docHome . '\ktdbbackup.sql');

    #create csv to restore original documents just in case
    $sql = 'select * from documents, document_content_version, users where documents.status_id = 1 and document_content_version.document_id = and documents.creator_id =';
    $result = mysql_query($sql);
    if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";

    $mycsvBackup = $docHome . "\ktbackup.csv";
    $fh = fopen($mycsvBackup, 'w');
    while ($row = mysql_fetch_assoc($result)) {
    fwrite($fh,$row["filename"] . "," . $row["storage_path"] . "," . $row["username"] . "," . $row["md5hash"] . " \n");

    Poor Man’s TS Universal Print Driver

    All the terminal services print drivers I found were too expensive for a 2 user TS environment that I was maintaining.

    • On the client download and install this open source pdf print driver for windows
    • Setup the pdf printer to automatically print to the client printer and to auto save.
    • On the server install the open source pdf print driver and delete the printer it creates so now you have the drivers on the server.

    From the client connect to the terminal server and print a test page, you should get a print pop up asking to confirm the print settings.

    The reason this works is that the pdfforge will send the PS document to the client computer to be processed. The best benefit is that its all free.

    Active Directory Computer Accounts

    I found this utility oldcmp on the internet that makes it easier to find old computer accounts in active directory.

    You have to be careful with this utility so you do not accidentally delete computer accounts that are being used.

    Another note, in my testing Macintosh computers do not update their computer password as frequently as PCs do.

    Expand a Logical Drive using existing free space on a DS3200.

    Here is the command for smcli to expand an existing Logical Drive. I had to mix documentation from Dell, IBM, and SANtricity to get a working command line. The ; at the end of the line is required. i just ran smcli localhost and pasted the below command.

    This is not the same as add capacity in the GUI.

    Here is the command information to expand the drive in windows.

    set logicaldrive["name or label of logical drive"] addCapacity=SizeinBytes;

    Using perl to Parse AD’s UserAccountControl field

    To parse the UserAccountControl field in Active Directory you have to use a bit-wise and of “&” and not “&&” to check the value. Below are some examples Here is a MSDN page that has more information.

    This MS site also has more values listed.

    #Check if the account is Disabled
    $strStatus & 2
    #Check if the account is Locked
    $strStatus & 16