SambaLogonTime

To save the logon time of each user with a samba pdc use the following procedure

yum install ruby ruby-devel rdoc
cd /usr/local/src

Newer releases of fedora >5 will install rubygems with yum

wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar -zxvf rubygems-0.9.2.tgz
cd rubygems-0.9.2
ruby setup.rb
gem install ruby-net-ldap
gem install ruby-net-ldap
cd

I'm doing this as root so you should be in the root directory now "/root/"

Download the ldapctl script:

wget http://go.sneakymustard.com/stuff/code/ldapctl.rb

or, now it resides on my server

wget http://www.dghartung.com/samples/ldapctl.rb

I had to modify line 99 in the script to accommodate my use, change line 99 from :

CONFIG = ENV['HOME'] + '/.ldapctlrc'

TO

CONFIG = '/root/.ldapctlrc'

Create a config file named .ldapctlrc with the following contents suited for yourself

mydomain:
  host:       127.0.0.1
  port:       389
  bind_dn:    cn=Manager,dc=dghartung,dc=com
  base_dn:    dc=dghartung,dc=com
  password:   passwd
  dn_pattern: uid=%s,ou=People,dc=dghartung,dc=com

Change to the /usr/local/bin directory

cd /usr/local/bin

Create a file called smbupd.sh with the following contents

#!/bin/bash

TIMESTAMP=$(date +%s)

/usr/bin/ruby /root/ldapctl.rb mydomain replace $1 sambaLogonTime "$TIMESTAMP"

Make sure it is executable

chmod 755 /usr/local/bin/smbupd.sh

Now Modify your /etc/samba/smb.conf file. In your netlogon share place the following line

root preexec = /usr/local/bin/smbupd.sh "%U"
Comments