Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant database privileges in DB2 to other Domain users

Tags:

java

db2

In a Java application, I have created 2 databases in DB2 with administrative authorities. Now using an application, want to access same databases over LAN but need to grant database privileges to other (in same Domain) Domain users, so that they can access the same databases as a end users.

I have tried DB2 GRANT command, but it doesn't allow others to access those database, But if they use same user/pwd as of Administrator, DB2 allow them to access databases. But it may be security issue to know the Administrator user/pwd.

Is there any way to do this on command prompt i.e. db2cmd

GRANT CONNECT,ACCESSCTRL,DATAACCESS,DBADM,SECADM ON DATABASE TO USER Kishore

This command doesn't solve the issue.

Thanks in advance.

I did as @Ian Bjorhovde suggested. Now the DB2 services are running as Domain\Admin and GRANT command is successfully executed but still other Domain users are not able to connect to DBs (with their own authentications) which are created by Admin. This code is used

DriverManager.getConnection("jdbc:db2://SERVERNAME:50000/TESTDB", UserName, PassWord);

The connection is created but throws SQL exception (SQLCODE=-204) while firing any SELECT query even on supplied the UserName as Domain\UserName.

like image 571
Kishore_2021 Avatar asked Nov 18 '25 03:11

Kishore_2021


1 Answers

To authenticate against the domain, the DB2 Service (instance) must be running using a domain account - it can't be started using an account defined on the local machine. You can stop your instance and then from the Windows Services panel change the DB2 service to start using a domain ID.

Make sure that this domain ID has sufficient privileges, as documented here.

like image 164
Ian Bjorhovde Avatar answered Nov 19 '25 17:11

Ian Bjorhovde