Sunday, December 14, 2014

Lotus Notes - Error: "Time Is Too Far in the Future"

If you encouter this error message - Error: "Time Is Too Far in the Future" - when you run nfixup, ncompact, nupdall, etc... Or, you suddenly realized that your Inbox is not displaying recent email, you are most like hit by "Future Date Issue"

To verify whether you had been hit by "Future Date Issue", you can do the following

1. Go to your Inbox then click Alt+Enter. This will open up a document properties dialog
2. Switch to database properties
3. Click on "I" tab and check on the Activity date. If the modified date is in the future, it means that you had been hit by "Future Data Issue"

When this happen, new document will be hidden in your Inbox because they have a delivery date that is in the future. However, you could still see your incoming email from All Document folder.

To fix this, you will have to create a new replica with the following step

1. In your Mail view, go to File -> Replication -> New Replica...
2. It will prompt up a dialog box. Enter a correct Server and File Path. Then click Ok. (It will be best to backup your current nsf file before creating a new replica)
3. It will take awhile to create the new replica depending on the data need to be copy and synchronized from the server.

After the above steps, you should have a new replica with a correct modification date. You can look at the database properties to verify it.

The above is something that works best for me after trying other methods like running nfixup/nupdall command, create a new view with "Future Date" formula, etc...

Reference:

1. https://keithbalomben.wordpress.com/tag/nfixup-exe/
2. https://www-304.ibm.com/support/docview.wss?uid=swg21161751
3. http://lotusibm.com/database-corruption-and-troubleshooting/

Tuesday, November 25, 2014

Teradata - ODBC.ini Entry Explained

Actually, detail of Teradata odbc.ini structure can be found in ODBC Driver for Teradata
User Guide. But, it is a 228 pages document. So, the purpose of this blog entry is to provide essential summarized information about what is required in the odbc.ini for connecting to a Teradata database.

Below describe the required tag for the Teradata specific odbc.ini file

ODBC Options Section

This section mainly define the ODBC Driver installation directory.

[ODBC]
InstallDir="filepath" //Required. You should provide the full path for Teradata ODBC Driver installation directory. An example default installation directory is /opt/teradata/client/ODBC_64.

ODBC Data Sources Section

This section define the the Data Source Name (DSN) and its corresponding Teradata ODBC Driver

[ODBC Data Sources]
data-source-name="driver" //Required. Provide the DSN and its driver name. An entry for each data source. The driver file should have either .so or .sl extension

Data Source Specification Section

This section define the data source specification for each data source entry listed in the ODBC Data Source Section. The in this section correspond to the ODBC Data Source Section data-source-name.

[data-source-name]
Driver="driver-path" //Required.  The full path to the Teradata ODBC Driver shared object file. It should be a .so or .sl file
Description="data-source-desc" //Optional. Provide a description for this data source entry
DBCName="IP-addr-or-alias" // Required. The IP address or FQDN (fully qualified domain name) of the Teradata server. This can be multiple entries
Username="name" //Optional. The username to be used by this data source name entry
Password="password" //Optional. The password for the username defined in Username tag.
DefaultDatabase="database-name" //Optional. The default database for this data source name entry

32-bit odbc.ini File Example

[ODBC]
InstallDir=/opt/teradata/client/14.00/odbc_32

[ODBC Data Sources]
your_default=tdata.so
your_testing_dsn=tdata.so

[your_testing_dsn]
Driver=/opt/teradata/client/14.00/odbc_32/lib/tdata.so
Description=My testing Teradata database
DBCName=182.123.111.222
DBCName2=44.55.22.11
DBCName3=your_teradata_database.com

[your_default]
Driver=/opt/teradata/client/14.00/odbc_32/lib/tdata.so
Description=My Default DSN
DBCName=10.10.10.10

64-bit odbc.ini File Example

[ODBC]
InstallDir=/opt/teradata/client/14.00/odbc_64

[ODBC Data Sources]
your_default=tdata.so
your_testing_dsn=tdata.so

[your_testing_dsn]
Driver=/opt/teradata/client/14.00/odbc_64/lib/tdata.so
Description=Yet another testing DSN
DBCName=12.34.56.78
Username=my_test_id
Password=my_test_password
DefaultDatabase=my_database

[your_default]
Driver=/opt/teradata/client/14.00/odbc_64/lib/tdata.so
Description=Yet another default database
DBCName=87.65.43.21
DBCName2=default_database.com
Username=my_default_user
Password=my_default_password
DefaultDatabase=my_default_database

Reference
1. ODBC Driver for Teradata User Guide 

Saturday, October 11, 2014

ODBC - [08001][unixODBC]Could not connect to the server; Could not connect to remote socket immedaitely [ISQL]ERROR: Could not SQLConnect

If you encounter the following error when you test odbc connection with isql

[08001][unixODBC]Could not connect to the server;
Could not connect to remote socket immedaitely
[ISQL]ERROR: Could not SQLConnect

You may have an error in your odbc.ini file. To be specific, you could be using a wrong "key" name for the server or port in your odbc.ini.

Some background. odbc.ini define DSN information in a key-value pair format and the key is vendor specific. Below is an erratic odbc.ini file entry

 [MSSQL2005]
Driver = ODBC Driver 11 for SQL Server
Description = Microsoft SQL ODBC Driver
Server = your_mssql_server_host
Port = 1433
Database =
[POSTGRESQL9] Driver = PostgreSQL9 Driver
Description = Postgresql ODBC Driver
Server = your_postgresql_server_host
Port = 5432
Database = your_database

With the above entry, MSSQL2005 DSN will work but POSTGRESQL9 DSN will fail.

unixODBC isql will return the following if you try to query POSTGRESQL9 DSN

[shell]$ isql -v POSTGRESQL9 your_user your_password
[08001][unixODBC]Could not connect to the server;
Could not connect to remote socket immedaitely
[ISQL]ERROR: Could not SQLConnect

The problem is.... PostgreSQL does not understand

Server = your_postgresql_server_host

The correct syntax is

Servername = your_postgresql_server_host

So, to fix the error, the correct odbc.ini entry is

 [MSQL2005]
Driver = ODBC Driver 11 for SQL Server
Description = Microsoft SQL ODBC Driver
Server = your_mssql_server_host
Port = 1433
Database =
[POSTGRESQL9] Driver = PostgreSQL9 Driver
Description = Postgresql ODBC Driver
Servername = your_postgresql_server_host
Port = 5432
Database = your_database

Sunday, September 21, 2014

ODBC - Testing odbc.ini in Linux

It is always best to test the ODBC configuration in the odbc.ini externally before doing real work with the database. Before putting the commands right away, below is a brief description about ODBC

ODBC, Open Database Connectivity, objective is to provide a standard API for accessing DBMS. It has 2 parts, the driver manager and the driver.

Driver Manager

It is a layer between the application and the actual driver. It actual functions include resolving DSN (Data Source Name) through the odbc.ini, loading and unloading the actual driver and pass application database calls to the driver.

The common ODBC Driver Manager are

Windows -  Microsoft Windows ODBC Driver Manager (odbc32.dll).

Unix - 2 commons Unix Driver Manager are

unixODBC Driver Manager for Unix (libodbc.so). See http://www.unixodbc.org, for more information.

iODBC Driver Manager for Unix (libiodbc.so). See http://www.iodbc.org, for more information.

Driver

It is vendor specific. When the Driver Manager passes the standard database call from the application, it translate to DBMS specific functions and commands to query the designated DBMS.

You could download the driver from the specific database vendor or you can use Easysoft or Datadirect which support large number of databases.

Testing ODBC Connectivity

After creating the DSN entry in your odbc.ini (either in /etc/odbc.ini which need root privilege or user .odbc.ini), you can use the following commands to test the odbc.ini file, assuming that you are using unixODBC driver

isql -v my_dsn myusername mypassword

Saturday, August 30, 2014

Unicode - Unicode vs UTF-8


Well, they can't be compare. Because unicode is a single character set that match a number for every character in the world written system. UTF-8, in another hand, is an encoding algorithm to store the unicode number on disk. There are many encoding algorithm beside UTF-8, ie ASCII, EBCDIC, etc.., but, there is only one Unicode system for all these encoding algorithm.

I really like the following posts that tell us about Unicode and UTF-8

http://rrn.dk/the-difference-between-utf-8-and-unicode

http://www.joelonsoftware.com/articles/Unicode.html

Some list of unicode code page

http://unicode-table.com/en/
http://en.wikipedia.org/wiki/List_of_Unicode_characters

Monday, July 28, 2014

LDAP - Configuring OpenLDAP

In previous post LDAP - Installing OpenLDAP, I listed down the steps to install OpenLDAP. In this post, I will list down the step to add LDAP entry for OpenLDAP

I will use LDIF and ldapadd to add LDAP entry into OpenLDAP database.

The LDAP Data Interchange Format (LDIF) is used to represent LDAP entries in a simple text format. And ldapadd is a utility which shipped with OpenLDAP to add LDAP entry

Adding an Organization Role

1. Create a LDIF file, ie, organization_roles.ldif
2. Add the following into organization_roles.ldif

# Organization for Example Corporation
dn: dc=example,dc=com
objectClass: dcObject
objectClass: organization
dc: example
o: Example Corporation
description: The Example Corporation

# Organizational Role for Directory Manager
dn: cn=Manager,dc=example,dc=com
objectClass: organizationalRole
cn: Manager
description: Directory Manager

The above create a organization role "Manager" in example.com LDAP directory.

3. Use ldapadd command to add the entry

Assuming that slapd.conf has the following entry

rootdn "cn=Manager,dc=example,dc=com"
rootpw secret

Then, you can use the following command to add a LDAP entry

ldapadd -f organization_roles.ldif -x -D "cn=Manager,dc=example,dc=com" -w secret

where
-f    # file name which contains the entry
-x   # Use simple authentication instead of SASL
-D   # Use the Distinguished Name binddn to bind to the LDAP directory. (Username, usually rootdn)
-w   # the password for simple authentication (password for rootpw)

4. On successful adding, you should see the following on the stdout

adding new entry "dc=example,dc=com"

adding new entry "cn=Manager,dc=example,dc=com"

Adding Multiple Users

1. Create a LDIF file, ie, users.ldif
2. Add the following into users.ldif

# Admin's Entry
dn: cn=Admin,dc=example,dc=com
cn: Administrator
objectClass: person
sn: Admin

# User1's Entry
dn: cn=User1,dc=example,dc=com
cn: User1
objectClass: person
sn: User1

# Eric Simpson's Entry
dn: cn=Eric Simpson,dc=example,dc=com
cn: Eric Simpson
cn: Eric Robert Simpson
objectClass: person
sn: Simpson

3. Use ldapadd command to add the entry 

ldapadd -f users.ldif -x -D "cn=Manager,dc=example,dc=com" -w secret

where
-f    # file name which contains the entry
-x   # Use simple authentication instead of SASL
-D   # Use the Distinguished Name binddn to bind to the LDAP directory. (Username, usually rootdn)
-w   # the password for simple authentication (password for rootpw)

4. Verify your entry with ldapsearch

ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'

where

-x    # Use simple authentication instead of SASL
-b   # the starting point for the search
(objectclass=*)    # It is the filter to be applied for the search. In this case, any objectClass

Reference:

1. http://www.openldap.org/doc/admin24/dbtools.html
2. http://www.openldap.org/software/man.cgi?query=ldapadd&apropos=0&sektion=0&manpath=OpenLDAP+2.0-Release&format=html

Monday, June 30, 2014

LDAP - Installing OpenLDAP

Now, I need to play with LDAP. So, what is LDAP?

LDAP (Lightweight Directory Access Protocol) is an industry standard application protocol for accessing and maintaining distributed directory information server over an Network

Then, what is OpenLDAP? Well, it is an open-source implementation of LDAP.

For some reason, their default downloading mirroring sites are either timing me out or not valid. So, it will be easier to download OpenLDAP from their FTP over HTTP site (http://www.openldap.org/software/download/OpenLDAP/)

This notes will only be a high level guide on the steps (which I had tried) to install OpenLDAP. It will also highlight the problems and solutions during the installation

Prerequisites

OpenLDAP has the following prerequisites

1. Require Transport Layer Security services. I would suggest to use OpenSSL. By default, during the configuration, it will detect whether any TLS library is available. If you want to check whether your system support OpenSSL, you can try
openssl version
to check the currently install OpenSSL version

2. Require Cyrus SASL libraries to provide Simple Authentication and Security Layer services. To check if SASL is installed, you can use
ls -al /usr/lib/sasl2
to check whether the library exist

3. Install MIT Kerberos if you need Kerberos support from OpenSSL

4. Require Oracle Berkeley Database. BDB and HDB is the primary database backends for OpenLDAP

Now, during configuration, if you encounter the following error

checking for Berkeley DB major version in db.h... 4
checking for Berkeley DB minor version in db.h... 3
checking if Berkeley DB version supported by BDB/HDB backends... no
configure: error: BerkeleyDB version incompatible with BDB/HDB backends
This means that you need to upgrade your Berkeley Database because OpenLDAP support database version >= 4.4. You can do the following to upgrade your Berkeley Database

Installing the latest Berkeley Database

You can get the latest installer from http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html

For some reason, although Oracle said that the download is Berkeley DB X.X.XX.tar.gz, the downloaded file is call db-X.X.XX.gz (X.X.XX is the current version number). So assuming that X.X.XX is 6.0.30, all you need to do is to change db-6.0.30.gz to db-6.0.30.tar.gz and use tar -zxvf db-6.0.30.tar.gz to extract the installation file.

Now, you can follow these instruction to install latest Berkeley Database http://docs.oracle.com/cd/E17076_03/html/installation/build_unix.html

Export Paths before performing ./configure

You need to export the following (assuming that the downloaded version is 6.0.30)

export LD_LIBRARY_PATH="/usr/local/BerkeleyDB.6.0/lib"
export CPPFLAGS="-I/usr/local/BerkeleyDB.6.0/include"
export LDFLAGS="-L/usr/local/BerkeleyDB.6.0/lib"   

The above will tell ./configure to look for the latest Berkeley Database for library linkage

Installation

Below are the summary steps for installation

1. Get the installation package. The current version is openldap-2.4.39.tgz. and I will use this as an example
2. Unpack the installation
gunzip -c openldap-2.4.39.tgz | tar xvfB -
3. Navigate to the OpenLDAP installation directory
cd openldap-2.4.39
4. Run configure
./configure
5. Build the software
./make depend
./make
6. Test the build
./make test
7. Install OpenLDAP. Usually, it will installed in /usr/local
su root -c 'make install'
or
sudo make install
8. Edit the configuration file at /usr/local/etc/openldap/slapd.conf as root

Add the following (using example.com as example)
database bdb
suffix "dc=example,dc=com"
rootdn "cn=Manager,dc=example,dc=com"
rootpw secret
directory /usr/local/var/openldap-data
9. Start slapd (Standalone LDAP Daemon)
su root -c /usr/local/libexec/slapd
or
sudo /usr/local/libexec/slapd
Note: 

If you encounter the following error
/usr/local/libexec/slapd: error while loading shared libraries: libdb-6.0.so: cannot open shared object file: No such file or director
It means that you had not set up the shared library for Berkeley Database 6.0 correctly. You can use the following steps to fix it.

a. Create a file at /etc/ld.so.conf.d/db-6.conf 
b. Add /usr/local/BerkeleyDB.6.0/lib in the above file
c. Then, update library cache with sudo ldconfig
d. Run sudo /usr/local/libexec/slapd to test the setting

To check to see if the server is running and configured correctly, you can run the following command
ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts
It should display (using example.com as example)
dn:
namingContexts: dc=example,dc=com
The above should help you to set OpenLDAP up and running. If you want to know the details about the setup, see http://www.openldap.org/doc/admin24/quickstart.html for full installation details.

References:

1) http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol