Determine Microsoft Exchange CD Key from the Windows Registry

Have you ever come across an Exchange server that needed to have Exchange re-installed, but you couldn't find the original CD key for the installation? You can look into the Windows Registry and determine the key. Here is the location:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Integration\*CRAZY HASH*\

Where *CRAZY HASH* is some random string of characters and dashes like 12A456B8-12AB-1234-ABDC-BC321CD123DA12

Inside that key you'll have a string with the name PID3.0 whose value is the CD key!

Share/Save/Bookmark

Default Password to Uninstall Symantec Antivirus Corporate Edition

If you have a computer that was at one time attached to a corporate network that is running a version of Symantec Antivirus Corporate Edition and you try to uninstall it, you'll see that there is a password required. The quick and easy answer to this question is to tell you that there is a default password, and it's symantec.

However, if the administrator changed the password, as any security-conscience administrator would, here are the steps involved in bypassing it:

Open the Windows Registry Editor  (regedit) and browse to:

HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\Administrator Only\Security\

Open the UseVPUninstallPassword key and change the value from 1 to 0

Close the registry and try to uninstall Symantec again. You should no longer be prompted for the uninstall password!

Share/Save/Bookmark

Sendmail as a Gateway to a LAN Mail Server

These are the steps involved in setting up a default installation of Sendmail (8.13.8) in Red Hat Enterprise Linux 5.1 (CentOS 5.1, etc) as a mail gateway from an external (public) address to an internet LAN (Local Area Network) mail server.

Required Packages:

  • sendmail
  • sendmail-cf

If you need help installing a package, please read how to install packages using YUM.

First off we're going to check that the /etc/hosts file is correct as Sendmail needs to determine the host name by this:

cat /etc/hosts
127.0.0.1 ux-mail.example.com ux-mail
localhost.localdomain localhost

By default Sendmail is listening on the loopback interface, which means it only allows mail to be sent from the server it is running on. Sendmail needs to be configured to listen on the NIC (Network Interface Card) as Sendmail needs to act as a server.

We have to edit /etc/mail/sendmail.mc to make Sendmail listen on the NIC. To make Sendmail skip a certain command, we have to add dnl (delete to new line) to the beginning of the line, since it will then be skipped by the M4 processor. In this case, we want to tell it to skip the command that binds it to the local loopback adapter by changing a line:

Change the line:

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA')

To:

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA')

Do the same to the following line to take precautions against spam by not accepting mail from a domain that doesn't exist:

Change the line:

FEATURE(`accept_unresolveble_domains')

To:

dnl FEATURE(`accept_unresolveble_domains')

Also, to forward all *@example.com mail to int-mail.example.com server, add the mailertable feature to the Sendmail configuration file (/etc/mail/sendmail.mc). Add this line towards the bottom, before any MAILER() calls:

FEATURE(`mailertable')

Rebuild the sendmail.cf file and restart Sendmail for the changes to take effect:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Edit the /etc/mail/access file and add the following lines to allow relaying messages from an example server (192.168.100.30) and an example domain (example.com), just make sure to change the IP address to your server's address, and the domain to your domain name:

localhost.localdomain RELAY
localhost RELAY
127.0.0.1 RELAY
192.168.100.30 RELAY
example.com RELAY

Then we need to convert the /etc/mail/access file to a Sendmail readable database using makemap:

cd /etc/mail
makemap hash access < access

Next we have to add a line to our mailertable file so sendmail knows where to relay the mail for domain. Edit /etc/mail/mailertable and add:

example.com smtp:[192.168.100.30] # My int-mail.domain.com server

Now we convert the /etc/mail/mailertable file to Sendmail readable database using makemap:

cd /etc/mail
makemap hash mailertable < mailertable

We have to make sure there is no example.com entry in our local host names file by running Sendmail in test mode and showing a list of domains it considers local:

sendmail -bt -C./sendmail.cf

Should return somthing like the following:

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter

At the > prompt, enter the command:

> $=w

Which should return something like:

ux-mail.example.com
ux-mail
localhost.localdomain
localhost
[127.0.0.1]

Type /quit at the prompt to exit:

> /quit

Restart Sendmail to activate all the changes we've made:

service sendmail restart

And we're done!

Share/Save/Bookmark

Perform a MySQL search by relevance in PHP

If you have a database with multiple entries that are similar and you'd like to do a search, you're going to need a way to sort the results. Sorting by the number of times a keyword appears in a block of text is one way, and it's called search relevence. Here is a PHP functions for performing a MySQL database search and ording the results by relevence:

  1. function relevance_search($keyword_raw, $page, $perpage)
  2. {
  3.         $return = NULL;
  4.         $page = ereg_replace("[^0-9]", "", $page);
  5.         $perpage = ereg_replace("[^0-9]", "", $perpage);
  6.         $offset = ' OFFSET '.(($page-1)*$perpage)-1;
  7.         if ($page == 1) {
  8.                 $offset = '';
  9.         }
  10.         $keywords = explode(' ', $keyword_raw);
  11.         if (is_array($keywords)) {
  12.                 $i = 0;
  13.                 foreach($keywords as $value) {
  14.                         $chunk = mysql_real_escape_string($value);
  15.  
  16.                         if ($i > 0) {
  17.                                 $plus = ' + ';
  18.                                 $or = ' OR ';
  19.                         }
  20.                         $keyword_string = $keyword_string.$plus."(CASE WHEN body LIKE '%$chunk%' THEN 1 ELSE 0 END) + (CASE WHEN title LIKE '%$chunk%' THEN 1 ELSE 0 END)";
  21.                         $where_string = $where_string.$or."body LIKE '%$chunk%' OR title LIKE '%$chunk%'";
  22.                         $i++;
  23.                 }
  24.                 $sql = "SELECT *, (".$keyword_string.") AS relevance FROM table_name WHERE (".$where_string.") ORDER BY relevance DESC LIMIT ".$perpage.$offset;
  25.                 $query = mysql_query($sql);
  26.                 if (mysql_num_rows($query)) {
  27.                         $i = 0;
  28.                         while ($row = mysql_fetch_array($query)) {
  29.                                 $return[$i] = $row;
  30.                                 $i++;
  31.                         }
  32.                         mysql_free_result($query);
  33.                 }
  34.         }
  35.         return $return;
  36. }

This function returns all the data matching to inputted keywords, and return an array of results sorted beginning with most relevent (the highest count of keyword matches).

Share/Save/Bookmark

Compiling an Oracle Instant Client (OCI8) PHP Module

These are the steps involved in creating a PHP module for Oracle Instant Client (OCI8) 1.2.5 (or higher) in Red Hat Enterprise Linux 5.1 or CentOS 5.1. in an x86-64 environment.

Required Packages:

  • gcc
  • glibc
  • httpd
  • libaio
  • make
  • php
  • php-devel
  • php-pear

If you need help installing a package, please read how to install packages using YUM.

32 bit users note: The instructions are exactly the same for a 32 bit OS, just change /client64/ to /client/ in all the commands below.

First things first, go to Oracle:

http://www.oracle.com/technology/software/tech/oci/instantclient/index.html

and download and install the RPM packages for Instant Client Package - Basic and Instant Client Package - SDK. An Oracle Technology Network username/password is required to download the files.

Note: As of writing this, the latest version of the Instant Client package available was 11.1.0.1. If you downloaded a newer (or older) version make sure the use those version numbers in the steps below.

 After downloading the packages, install them using the RPM command:

rpm -Uvh oracle-instantclient-basic-11.1.0.1-1.x86_64.rpm
rpm -Uvh oracle-instantclient-devel-11.1.0.1-1.x86_64.rpm

Once those packages are installed, switch into a temporary directory and enter the following commands to set the required environmental variables:

export LD_LIBRARY_PATH=/usr/lib/oracle/11.1.0.1/client64/
export ORACLE_HOME=/usr/lib/oracle/11.1.0.1/client64/

Also, add those lines to the end of /etc/bashrc so the variables stay effective after reboot.

Note: The following command is only necessary for users installing a version of OCI8 prior to 1.2.5. If you just downloaded the latest version, you can skip this step.

The SDK headers need to be copied into the client library so the compiler can find them:

cp /usr/include/oracle/11.1.0.1/client64/* /usr/lib/oracle/11.1.0.1/client64/lib/

Now comes a challenge that took me a little while to figure out. We want to install the OCI8 package from PEAR, however the package is too large (more than 8 mb) to be handled in memory by the standard PECL installer, so we need to perform an extra step. We're going to use PECL to download the OCI8 package:

pecl -v download oci8

in this case the downloaded file is called  oci8-1.2.5.tgz. Now we use PEAR to install it:

pear -v install oci8-1.2.5.tgz

It should scroll through a bunch of stuff making sure you have the proper software and packages installed on the machine. If everything is in order, it will prompt for the location of the Oracle client libraries. We're going to spcify that it use the Instant Client, and we're going to tell it the location of the libraries with the following line:

instantclient,/usr/lib/oracle/11.1.0.1/client64/lib

When the compilation is complete, you should receive the message "Build process completed successfully". To add the module to PHP, switch into the /etc/php.d/ directory and create a file called oci8.ini, and in it put:

extension=oci8.so

64 bit users installing a version of OCI8 prior to 1.2.5 note:

The module that we just created has to be moved into the 64 bit modules folder

cp /usr/lib/php/modules/oci8.so /usr/lib64/php/modules/

Now all we have to do is restart Apache:

service httpd restart

and take a look at phpinfo() and we should now see a section for OCI8. 

If you're getting an error like:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - /usr/lib/oracle/11.1.0.1/client64/lib/libnnz11.so: cannot restore segment pret after reloc: Permission denied in Unknown on line 0

after compiling and installing an Oracle OCI8 module for PHP you might need to change your SELINUX settings to allow the execution of the oci8.so module or simply disable SELINUX altogether

Share/Save/Bookmark

Installing Packages Using YUM

These are the step invloved in installing an RPM based package automatically in Red Hat Enterprise Linux 5.1 (CentOS 5.1, etc) using the program YUM.

Required Packages:

  • yum

Most of the entries in this blog have a list of packages at the beginning that are required. Unless otherwise noted, the packages in the lists are all available via YUM (Yellowdog Updater Modified). Please see the documentation that came with your RHEL 5.1 or CentOS 5.1 distribution for installing YUM. Most likely, it's alreay installed on your system.

To install a program using YUM, all you really need to know is the name of the package, and a simple command. For instance, if you wanted to install the package 'httpd' (Apache) you would type:

yum install httpd

If you already have a version of Apache installed, and you want to upgrade it, you would type the command:

yum update httpd

If you want to remove (delete) a package, simply type:

yum remove httpd

For more information, please check out this link:

http://www.centos.org/docs/5/html/yum/

Share/Save/Bookmark

Obolus

Sing, O Muse, of confusion, hidden.
Where is Charon? For he's bidden
To provide the service, only he
Of river-ferry, for a fee.
Acheron, the final toil
Of the hero, shuffl'd from mortal coil.

Greater than a man was He
Who led His Army to the sea.
A King of Men, A God Devine,
Libations to Him, unwatered wine.
Across and beyond, far and wide
His soldiers followed, matching stride.

Many souls who remain un-named
Followed this Man to lands un-tamed.
And battle there, these slaves did.
And met their demise, lest they forbid
Death from collecting all that's his:
For Death knows all; sees all; is.

Assault, rage; long and bitter.
Mortals fought, died; none the gritter.
Numbers dwindled on the flanks,
The Monarch lost all men of rank.
Yet on He brawled, to the lines
To muster, rally, raise ensigns.

This Danaan King and his slaves,
Caste, status and fear they laved.
A clash of bronze, a shimmer of gold;
A furious sight, ere enemy, to behold.
And on they fought, with godlike might,
Until Tyche ended their plight.

A spear, thrust with Immortal verity,
Bound for the Prince, in all sincerity,
Struck, instead, a surf, a slave
Who gave his life, forever brave.
At this, the Magnate, in great despair,
Loosed fell words into the air:

"I give-up and give-in, I concede;
I mourn this slave, this man, un-freed.
Pray, I leave him silver coin,
The boatman's payment, to let him join
Kin and kindred, flesh and bone,
In immortal lands; not alone."

Mourn thee not, Argive Commander,
The slave is at peace; naught Scamander.
Charon the boatman ferries him now,
To the Elysian Fields, on his godly prow.
There is a price, all know it well,
To secure passage; escape from Hell.

Share/Save/Bookmark

« go back