Wednesday, November 24, 2010

LDAP Skills

Skill 1
---------------------------------------------------------------------
What is "log.XXXXXXXXXX" in the BDB backend directory?
Logs of current transactions need to be stored into files so that the database can be recovered in the event of an application crash. Administrator can change the size limit of a single log file (by default 10MB), and have old log files removed automatically, by setting up DB environment (see below). The reason Berkeley DB never deletes any log files by default is that the administrator may wish to backup the log files before removal to make database recovery possible even after a catastrophic failure, such as file system corruption.

The slapd_db_archive tool knows what log files are used in current transactions, and what are not. Administrators can move unused log files to a backup media, and delete them. To have them removed automatically, place set_flags DB_LOG_AUTOREMOVE directive in DB_CONFIG. Note that if the log files are removed automatically, recovery after a catastrophic failure is likely to be impossible.

The files with names __db.001, __db.002, etc are just shared memory regions (or whatever). These ARE NOT `logs', they must be left alone. Don't be afraid of them, they do not grow like logs do.

The "alock" is an autorecovery mechanism introduced in the OpenLDAP 2.3 release to assist with autorecovery. Given more information on the error messages coming from alock would be useful, since it is supposed to help you recover from hard reboots gracefully.

For recovered the BDB database.

How can we clear all the redundant log file?
slapd_db_archive -a: Identify BDB logs which is not in use, and can be safely deleted
slapd_db_archive -l: List all the log files in BDB
slapd_db_archive -d: Remove all the unused logs files
-----------------------------------------------------------------

Skill 2
------------------
How to recover OpenLDAP database?
we can repair the OpenLDAP database by the following command:
/usr/sbin/slapd_db_recover -v -h /var/lib/ldap
after recovery, make sure to chown the files back to ldap:ldap or else it will still be busted.

------------------
How to backup OpenLDAP database in form of LDIF to remote Server:
---------------------------------------------
1. Backup-Script(ldap.sh):
***************************
#! /bin/sh
cd /root
rm -f /var/ldap_backup.ldif
/usr/sbin/slapcat > /var/ldap_backup.ldif
mount -t cifs -o username=ldap,password=ldap123 //192.168.2.200/ldapbackup /var/backup
cp -rf /var/ldap_backup.ldif /var/backup/
umount /var/backup
***************************
2. How to run a sh script on linux OS:
# sh script file
---------------------------------------------
3. Add a cron job:
# crontab -l
# crontab -e
30 3 * * * sh /var/ldap.sh
----------------------------------------



Reference Site
1. http://www.zytrax.com/books/ldap/ch6/bdb.html

Tuesday, October 19, 2010

How to update samba from 3.0.33 to 3.3.8

How to update samba from 3.0.33 to 3.3.8

1. Backup all your samba related data and configuration files
2. Upgrade your server to Centos 5.4 or 5.5
3. Remove samba, samba-client, samba-common (yum remove package name)
4. Insert your Centos DVD and mount it to your server:
---------
a. mount -t iso9660 /dev/cdrom /media/cdrom/
b. vi /etc/yum.repos.d/CentOS-Media.repo , and Make sure enabled is set to 1: enabled=1
c.
Save and close the file. To use repo put your DVD and along with the other repos, enter:
# yum --enablerepo=c5-media install pacakge-name
d.
To only use the DVDmedia repo, do this:
# yum --disablerepo=\* --enablerepo=c5-media install samba3x
---------
5. Done.

Thursday, August 19, 2010

OpenWebMail

OpenWebMail

How to create multiple global address book:
1. Go to /var/www/cgi-bin/openwebmail/etc/addressbooks/, and create an empty file in this directory. Then this file will automatically be a global address book.
For example, i create a new global address book (command):
1. touch newbook
2. chown mailadmin.email newbook (My own setting - chown mamil:mail newbook)
3. chmod 640 newbook (My own setting - chmod 660 newbook)

Sunday, July 18, 2010

NAS

Download the application from : http://www.openfiler.com/

Wednesday, February 3, 2010

New Ideas

New Ideas

1.
--------------------------
Hand phone company should have a database to store infomation of each phone and their owner.
Under this strategy, it will reduce handphone's steal problem, because when user go to buy a new or second hand handphone and they can check the handphone status and last owner information. If they discover the phone is under crime. Then they can report it.
--------------------------

Monday, January 11, 2010

Tech

Tech

Using Msn Messenger In Old Version
---
Step1 – Go to Msn Messenger program folder
Step2 – Find out msnmsgr.exe, right click it and select property
Step3 – Switch to compatibility page, and tick compatibility mode.
Step4 – Select Windows 2000, finally click OK
---

Change default language typing (Word)
---------
1. Open Word Program.
2. Go to "Tools" , "Options" , and select "Edit" tag.
3. Cancel IME options"'s "IME Control Active".
4. Finish
---------

Change language typing (System)
-------
1. Go to "regedit"
2. Go to "HKEY_CURRENT_USER , Keyboard layout , Preload"
3. Sorting your language sequence here
4. Finish
-------

Friday, January 8, 2010

Import SambaSamAccount Attribute to existing LDAP

Import SambaSamAccount Attribute to existing LDAP

---------------------------------------------------------



// Connecting to LDAP
$ldapconn = ldap_connect ($ldaphost, $ldapport)
or die("Could not connect to $ldaphost");

$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

$dn="ou=Student,dc=newera,dc=edu,dc=my";
$filter="uid=testuser";
$justthese=array("description","uidnumber");
$sr=ldap_search($ldapconn,$dn,$filter,$justthese);
$info=ldap_get_entries($ldapconn,$sr);
print $info["count"]." entries returned

";

for($i=0; $i<$info["count"]; $i++)
{

//$aaa=$info[$i]["uid"][0];
//ldap_mod_add($ldapconn,"uid=" . $aaa .",ou=Student,dc=test3,dc=test2,dc=test1",$entry);
//echo $info[$i]["uid"][0]."
";

//$uuu = $info[$i]["uid"][0];
$kkk = $info[$i]["description"][0];
$mmm = $info[$i]["uidnumber"][0]*2+1000;
$nnn = "S-1-5-21-3242087124-4121386262-3365014982-";
$ppp = $nnn.$mmm;
echo $kkk;

//-------------------
$con = mysql_connect("$hostname","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("studentemail", $con);

$result = mysql_query("SELECT * FROM student
WHERE student_id='$kkk'");

while($row = mysql_fetch_array($result))
{
$yyy = $row['student_ic'];
$zzz = rtrim(shell_exec("/usr/local/bin/mkntpwd -N $yyy"));
echo $row['student_ic'];
echo "
";
}
//--------------------

//add new attribute
$entry["objectClass"]="sambaSamAccount";
$entry["sambaSID"]=$ppp;
$entry["sambaDomainName"]="lab";
$entry["sambaAcctFlags"]="[U]";
$entry["sambaPwdLastSet"]="1262395503";
$entry["sambaNTPassword"]=$zzz;
ldap_mod_del($ldapconn,"uid=testuser,ou=Student,dc=test3,dc=test2,dc=test1",$entry);

}

?>
---------------------------------------------------------------------------------------------