Backing up JCAPS repository

A quick script to backup JCAPS repository and only keep a certain number of backups:

' Script to perform backups for the JCAPS environments and make sure that only the last 15 days of backups are kept
' This is done because it is run through cron.

' Set the maximum number of backups to keep
MaxBackups = 15
' Get the list of all the files in the backup directory and sort into order.

Set fso = CreateObject("Scripting.FileSystemObject")

Set list = CreateObject("ADOR.Recordset")
list.Fields.Append "name", 200, 255
list.Fields.Append "date", 7

' Get all of files and the attributes
For Each f In fso.GetFolder("C:\JCAPSRepositoryBackup").Files
  list("name").Value = f.Path
  list("date").Value = f.DateLastModified
' Sort the list
list.Sort = "date ASC"
' Get the first item in the list

for i=1 To list.RecordCount - MaxBackups
  ' Now, do the clean up and delete the file

' Now, do a repository backup
Set objShell = CreateObject("WScript.Shell")
command = "c:\JavaCAPS63\repository\repository\util\backup.bat #username# #password# c:\JCAPSRepositoryBackup\backup" & DatePart("yyyy", Now)&DatePart("m", Now)&DatePart("d", Now)&DatePart("h", Now)&DatePart("n", Now) & ".zip"


Using microsoft SQL to query Active Directory

This is a post to document a setup of a query from two active directories and population into a SQL table. This is written as a stored procedure which can then be configured to run on a user defined schedule.

The setup is that disabled accounts are created and moved around in the DOMAIN domain and new accounts are created in a specific OU in the RCH domain. I’m interested in this movement and configuration and as such I have limited some of the queries to active / deactive users and specific OUs and resources.
Continue reading

Postfix and courier ldap auth failure

migrating to a different mail server has created some headaches for my postfix implementation. The problem according to the logs is:

root@lrrr:/var/run/courier# tail -f /var/log/mail.log
Jul 29 11:56:27 lrrr postfix/smtpd[17544]: warning: SASL authentication failure: cannot connect to Courier authdaemond: No such file or directory
Jul 29 11:56:27 lrrr postfix/smtpd[17544]: warning: SASL authentication failure: Password verification failed
Jul 29 11:56:27 lrrr postfix/smtpd[17544]: warning: unknown[]: SASL PLAIN authentication failed: generic failure
Jul 29 11:56:28 lrrr postfix/smtpd[17544]: warning: SASL authentication failure: cannot connect to Courier authdaemond: No such file or directory
Jul 29 11:56:28 lrrr postfix/smtpd[17544]: warning: unknown[]: SASL LOGIN authentication failed: generic failure

The problem it appears is that postfix can’t reach outside it’s chroot. The solution was found in this case: .

root@lrrr:/etc/postfix/sasl# /etc/init.d/courier-authdaemon stop
[ ok ] Stopping Courier authentication services: authdaemond.
root@lrrr:/etc/postfix/sasl# ls /var/run/courier/authdaemon/
pid       pid.lock  socket
root@lrrr:/etc/postfix/sasl# mv /var/run/courier/authdaemon/ /var/run/courier/authdaemon.20140729
root@lrrr:/etc/postfix/sasl# mkdir -p /var/spool/postfix/var/run/courier/authdaemon/
root@lrrr:/etc/postfix/sasl# ln -s /var/spool/postfix/var/run/courier/authdaemon/ /var/run/courier/authdaemon/
ln: target `/var/run/courier/authdaemon/' is not a directory: No such file or directory
root@lrrr:/etc/postfix/sasl# ln -s /var/spool/postfix/var/run/courier/authdaemon/ /var/run/courier/authdaemon
root@lrrr:/var/run/courier# ls -lah
total 8.0K
drwxrwxr-x  3 daemon daemon 160 Jul 29 15:23 .
drwxr-xr-x 27 root   root   960 Jul 29 11:29 ..
lrwxrwxrwx  1 root   root    46 Jul 29 15:23 authdaemon -> /var/spool/postfix/var/run/courier/authdaemon/
drwxr-x---  2 daemon daemon 100 Jul 29 11:59 authdaemon.20140729
-rw-r--r--  1 root   root     5 Jul 21 09:57
-rw-------  1 root   root     0 Jul 21 09:57
-rw-------  1 daemon daemon   0 Jul 21 09:58 ldapaliasd.lock
-rw-r--r--  1 daemon daemon   5 Jul 21 09:58
root@lrrr:/var/run/courier# /etc/init.d/courier-authdaemon start
[ ok ] Starting Courier authentication services: authdaemond.
root@lrrr:/var/run/courier# postfix reload
postfix/postfix-script: refreshing the Postfix mail system

SQL server authentication

This is a quick post on how to run SQL enterprise manager as another domain user. This is because I am normally logged in as a lower privileged account and require advanced rights to access our enterprise databases. This uses the good old runas command and requires you to put in a password to proceed.
Create a shortcut on your machine, in the properties type:

C:\Windows\System32\runas.exe /netonly /user:domain\bowdena-a "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"

IIS mod rewrite

I have fought with IIS for a few hours trying to do what I can do in apache with a simple Alias statement and have finally managed to get to a permanent solution. The idea is that there is a subfolder under a site which has quite a large CMS component, the structure looks kind of like:
- Admin
- SelfService
- OtherComponent

All of these have different settings for application pools which creates a complication. The site has been pointed to by, the SelfService component can be reached by and the request was that the SelfService module should be reached by
Continue reading

another collection of bits and bytes