Challenge of Day

Wednesday, February 11, 2009

How to automatically redirect a browser to another web page

You might have been looking for this basic question. Suppose that you have page1 but the whole contents have been moved to new address and at the same time you do not want remove page1 completely. How do you redirect visitors to new address automatically?
Two easy solutions:
1 - Use "refresh" meta command:
The syntax for the "refresh" meta command is
{meta http-equiv="refresh" content="N; URL=other-web-address"}
(do not forget to replace { with < and } with >)
where N is the approximate number of seconds that you want the current web page to be displayed before the browser automatically goes to the other web address. If N=0, then the browser should go immediately to the other web address.
Here is an example:
{meta http-equiv="refresh" content="4; URL="}

2 - Using JavaScript:
By using JavaScript, you can easily redirect user as well:
script language="javascript" type="text/javascript">
window.setTimeout('window.location=""; ',4000);
// --}

Be a winner in your daily challenges

Ali Khademi

Friday, February 6, 2009

Microsoft Office Communications Server Validation Fails


If you are stuck with this error message:

Failed to register user: User sip: @ Server
Failed registration response: [
SIP/2.0 404 Not Found
FROM: ;epid=epid00;tag=74c8a3b6cd
TO: ;tag=C86D3278207DF163521E38386B5EDDF5
CALL-ID: a5fa02f7a073435d90cfe146df393e28
VIA: SIP/2.0/TLS;branch=z9hG4bK9fc22973;ms-received-port=3086;ms-received-cid=700
AUTHENTICATION-INFO: Kerberos rspauth="602306092A864886F71201020201011100FFFFFFFF977F5DB20C9783B6FDD6516A0AF6F261", srand="D4C7A34D", snum="1", opaque="42D17134", qop="auth", targetname="sip/", realm="SIP Communications Service"
ms-diagnostics: 4005;reason="Destination URI either not enabled for SIP or does not exist";source=""

Then before surfing the web and going for extraordinary ideas, check if users you are introducing are:
1 - Memeber of RCTUniversalServerAdmins
2 - Make them administrator of local computer
3 - Make sure you have make them SIP Enabled. For this reason, after installation of Office Communications Server, in Active Directory Users, right click on the users and follow the SIP enable wizard.

Be a winner in your daily challenges
Ali Khademi

Thursday, February 5, 2009

How to catch Oracle DB Lock Culprit


If you have your data in Oracle database, you might want to know who (program, users) has caused a database lock. The follwing script will help you find out more about responsible program:

(select substr(username,1,10) from gv$session where sid=a.sid) as locker_name,
(select substr(osuser,1,10) from gv$session where sid=a.sid) as locker_osname,
(select substr(machine,1,20) from gv$session where sid=a.sid) as locker_machine,
(select substr(program,1,10) from gv$session where sid=a.sid) as locker_program,
a.sid, ' is blocking ',
(select substr(username,1,10) from gv$session where sid=b.sid) lockee_name,
(select substr(osuser,1,10) from gv$session where sid=b.sid) as lockee_osname,
(select substr(program,1,10) from gv$session where sid = b.sid) as lockee_program,
' with this dml:',
gv$lock a, gv$lock b, v$open_cursor o, v$sql s
a.block = 1
and b.request > 0
and a.sid = o.sid
and o.sql_id = s.sql_id
and a.id1 = b.id1
and a.id2 = b.id2;

You should connect to your database as SYS as SYSADM in order to be able to run this script. Columns of this script are self-explained. Use the last column to find the spot in the locker program to fix the issue.

Your next question might be how to kill the Oracle session responsible for this lock? There are two ways:
1 - In command prompt type: OraKill OraSID PID (PID comes from v$session)
2 - In SqlPlus: alter system kill session 'sid,serial#' immediate;

Be a winner in your daily challenges.
Ali Khademi

How to install a Local Certificate Authority on your Domain

As you know CA is issued by an Authority to certify that you are you! If you want to obtain a CA not only you should pay money but also you should submit your documents to issuer and prove that you are you!
Now suppose that you just want to test a software for example Microsoft Office Communications Server and you need a temporary CA. Solution is not that much complicated.
If you are Linux or Unix oriented, you need to download an OpenSSL software, install it on your server and issue a certificate.
If you are Microsoft oriented, it is much easier. In Windows 2003, Go to Start -> Control Panel -> Add Remove Programs -> Server components and select "Certificate services". You might need the installation CD. Follow the wizard:

1 - On the Certificate Authority Type page, verify that Enterprise root CA is selected, and then click Next.
2 - Enter the information for CA Identifying Information using the values in the preceding table. Click Next.
3 - On the Certificate Database Settings page, click Next to accept the default database and log locations.
4 - Click Yes to stop IIS.
5 - If you are prompted, provide the path to the Windows Server 2003, Standard Edition files.
6 - A dialog box may appear indicating that Active Server Pages (ASP) must be enabled. In response to whether you want to enable ASP now, click YES and close the dialog box.
7 - Click Finish.

Now you have your CA for your test server.

Be a winner in your daily challenges.

Ali Khademi.
P.S. In order to review our happy family diary, visit