How can I login oracle as sys account using oci or anyother libs - c++

I am try to make a tool to help create user and imp database after oracle database installed.
Because it is too difficult for my colleagues to deployment a new database by typeing commands.
Then i tried using oci to login oracle sys account,but oci replay a mistake “ORA-12154: TNS:could not resolve the connect identifier specified”,but a normal account is ok.Please tell me how can i connect oracle as sys.Thank you.

Oracle installation happens only once during deployment. So does importing of Database dumps. Why write a separate application to import/export DB dumps?
Sys account was not resolved from tnsnames.ora hence the ERROR.
You can:
Create normal user with sufficient privileges like
[oracle#App ~]$ sqlplus "/ as sysdba"
CREATE USER user1 IDENTIFIED BY userpass DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
GRANT CREATE SESSION, RESOURCE, CREATE VIEW, CREATE MATERIALIZED VIEW, CREATE SYNONYM TO user1;
Provide Import and Export script with necessary SQL statements.

Related

How can I call a custom Django manage.py command directly from code with specific database connection

i followed this solution to run customer django command programmatically , but it is limited for just one database connection.
I have django app configured with multiple database , is it possible to run custom django command using specific database connection?
exactly like when we use connections["DB_NAME_CONNECTION"].cursor() to execute an sql query
thanks a lot for your help!
One option is to create a new settings module (here's a guide) that contains your specific database connection configuration, and then use that settings module when using call_command():
management.call_command('mycommand', '--settings=mysite.settings.specificconnection')

Wso2 Userstore migration from LDAP to DB (Custom user store)

We are using WSO2 identity server with LDAP as a user store. Now we would like to replace LDAP with database because of huge load (> 10 Millions) and growing. I have migrated the users but how tenant details in wso2 core database could be set with the new user store. That is the user store xml details are stored in their tenant table. How this could be migrated. Or what are all the changes, configurations, needs to be set in wso2 identity server level.
At the moment we don't have exact mechanism to migrate data from one DB type to another. What we have is upgrading one version to another using same DB.
But you can do this migrating data from an LDAP to any DB like MySQL manually. If you can write an shell script to convert LDAP data toa csv file, its easy for you to move to a MySQL like DB in one import command.
Furthermore, I was able to find out some similar articles which can help you to migrate content from LDAP to MySQL [2],[3],[4]
The table structures of DB types can be found from [1].
Once you migrate the data to JDBC, you can change the custom-userstore.xml file with new connection values and restart the server. If you changed your primary user store, you need to change the user store configurations in user-mgt.xml file.
Please let me know if you need further help in migrating.
[1]https://docs.wso2.com/display/IS550/Data+Dictionary
[2] https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dfae020f-a3bf-4e9b-9614-eccf7890f8c6/how-to-extract-data-from-ldap-and-then-import-it-into-sql-database-for-quicker-retrieval?forum=transactsql
[3]Active Directory data into SQL table
[4] https://www.egnyte.com/blog/2014/01/how-we-migrated-millions-of-users-from-ldap-to-mysql-using-feature-flags/

Unable to explore tables as admin in apache superset

I've just installed apache superset following instructions at https://superset.incubator.apache.org/installation.html. I then login to the web interface as admin. I also loaded sample data with 'superset load_examples'.
If i go to 'Sources > Tables' and click on any of the tables ('wb_health_population', for example) i get an error: 'This endpoint requires the datasource wb_health_population, database or all_datasource_access permission'.
I check permissions set for the admin role and existing permissions: 'all_datasource_access' is not enabled for the admin role, and does not exist in the list of existing permissions.
As i told, i just followed standard instalation instructions from superset's doc website. Any help on this? Thank you.
EDIT: Superset version is 0.20.6, python's 3.6.3.
Try running superset init - this should initialize permissions.
See https://superset.incubator.apache.org/installation.html#superset-installation-and-initialization
(code-wise, init calls security.sync_role_definitions() which itself calls create_custom_permissions() which creates the said permissions)
I would also try all_database_access permission.

Using django south with a different set of database credentials

I'm building a Django app which connects to a PostgreSQL database, and the credentials that the app uses has quite limited permissions granted over the relevant tables.
I'd like to be able to use south to manage database migrations, but given that this picks up on the same credentials that Django uses, this throws an error as south cannot make any changes to tables it doesn't own.
Is there a way to specify that south should use a different set of credentials to manage migrations other than that specified by the application settings?
Yes : have another set of settings with different credentials for south migrations and use the --settings option when calling the migrate command.
NB : to avoid DRY violation, you can as well start your special settings file by importing * from the normal settings and just override the DB credentials.

Apache user permissions on PostgreSQL database

I'm planning to deploy a Django site using Apache + mod_wsgi and PostgreSQL on Ubuntu 10.04.
I intend to connect to the database using IDENT authentication. For this I need to create a Postgresql user for Apache (www-data). I have chosen not to make this a superuser or provide any special privileges.
I have then created a database. I actually did this twice during testing. The first time I set the Apache user as the owner; the second time I set the owner as myself (superuser), and granted all privileges on the database to the Apache user.
When I use the Django syncdb management command (as myself), the tables created are not accessible to the Apache user. This can be resolved by granting all permissions to the Apache user for each table, but that's a bit of a nuisance.
The alternative seems to be allowing access as a superuser.
Is it considered safe/acceptable for my project to access a local db as a Postgresql superuser, and is it safe to use IDENT authentication? If not, what is the common practice?
EDIT: I've since found that switching PostgreSQL to use md5 authentication for local connections makes life easier.
When using ident authentication, connections to the database are via the Apache user during normal operation. When Django management commands are used, the connections are via the current user.
If you use MD5, both situations will connect to the database using the details specified in the DATABASES section of your settings.py file, avoiding the problems listed above.
I'm still interested to know if using a PostgreSQL superuser is wise.
Having applications connect as a superuser is almost definitely unwise. Unless the application needs to actually create and/or drop databases itself (and this is extremely unlikely), I don't think it's ever necessary. If the application connects to a database as that database's owner, it is effectively a superuser within the confines of that database, which might not be too bad.
I generally have applications access the database using an account authenticating with MD5. It's possible, for example, to set up pg_hba.conf such that the application account is the only account that can use MD5 authentication, and all other users on the local machine use ident/peer authentication.
It sounds like what you actually needed here was a role to group the Apache user and the other Django users together, so you could grant them access en masse.
Postgresql does have ways to grant permissions for all tables etc in a schema at once, and also a way to specify default permissions to be applied to new objects. This previous answer may be helpful: How do you create a read-only user in PostgreSQL?
IDENT authentication ended up being more hassle than it was worth. Here's what I ended up doing to avoid the use of a PostgreSQL superuser role...
Switch to the postgres linux user:
sudo su - postgres
Edit the PostgreSQL host-based authentication configuration file:
nano /etc/postgresql/8.4/main/pg_hba.conf
Scroll to near the bottom of this file, looking for the line which looks like this:
local all all ident
Change ident to md5, exit and save. This tells PostgreSQL to use an MD5-encrypted password for authentication on local connections. Now restart PostgreSQL:
/etc/init.d/postgresql-8.4 restart
Create a PostgreSQL user:
createuser django_user --pwprompt
Don't accept any of the special privileges when prompted. Now create a new database:
createdb -E UTF8 -O django_user django_db
Those options encode the database in UTF8 and set the owner to django_user. You can now exit back to the original linux user account:
exit
Your project settings file (settings.py) will need to include something like this:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'django_db',
'USER': 'django_user',
'PASSWORD': '[your password]',
'HOST': '',
'PORT': '',
}
}
When you run python manage.py syncdb or any other Django management commands, the settings above will be used to authenticate with the database.