Thursday, September 29, 2011

By default if a user has Operating System System administrator privilege he can connect to the oracle database without providing any password:
For example in windows operating system if I am connected as the Administrator use I can easily connect using the command sqlplus / as sysdba as shown below:


Lets see how we can avoid this:

1. Create a user in windows by Right clicking of My Computer icon given in the Desktop and selecting Manage and then select the Local Users and Groups.

Here I have created a user by the name of tamal.

Now logout from the Administrator account and login as the Tamal user

Next let us try connect as the OS user again.

As we can see Oracle returns us error code : ORA-01017.

This makes it clear that c:> sqlplus / as sysdba or SQL>conn / as sysdba only works if the operating user is a system administrator.

Oracle database doesn't allow non-administrator to connect because oracle database is not aware of them.

In order to allow non-system administrator to connect to the oracle database must:
  1. Create a database user with the same name as the OS user prefixed by the os_authent_prefix value.
  2. Grant the connect previlege to him.
To perform lets first identify what is the value of os_authent_prefix:
 

 Then create the database user by the name of the OS user prefixed by the value of os_authent_prefix (in windows OS you need to know the domain name):




Grant the user connect privilege:


Try to connect:


As we can see both the connect method are working.

Tuesday, September 13, 2011

The /etc/hosts file

If you are not using DNS server for connecting to other nodes in the network then chances are you are using the configuration of the /etc/hosts file for node connectivity.

This is especially useful for small sites. In this setup every node of the network keeps its own copy of the hosts file which contains the hostname and IP address in the /etc/hosts file of all the nodes which are part of network.

The structure of the /etc/hosts file is very simple. It consists of basically three columns the IP address, their corresponding hostname and the third column generally stores the short version of the hostname.

For example in a simple network of two nodes node1.oracle.com and node2.oracle.com with IP address 192.9.201.5 and 192.9.201.6 respectively then the /etc/hosts of each node file will look like this:

127.0.0.1              localhost.localdomain               localhost
::1                          localhost6.localdomain6           localhost6

192.9.201.5          node1.oracle.com                    node1
192.9.201.6          node2.oracle.com                    node2

In the above file the address 127.0.0.1 is to specify the loopback address for IPv4.
The ::1 is the loopback address for IPv6.