{"id":18,"date":"2012-04-19T09:36:00","date_gmt":"2012-04-19T09:36:00","guid":{"rendered":"http:\/\/anjo.pt\/wp\/keyword-oracle\/2012\/04\/19\/datapump-remap_schema-and-passwords\/"},"modified":"2015-11-17T20:27:23","modified_gmt":"2015-11-17T19:27:23","slug":"datapump-remap_schema-and-passwords","status":"publish","type":"post","link":"https:\/\/anjo.pt\/keyword-oracle\/2012\/04\/19\/datapump-remap_schema-and-passwords\/","title":{"rendered":"Datapump, remap_schema and passwords"},"content":{"rendered":"<p>Something that is quite logical after you think about, but surprises you at first.<\/p>\n<p>When you do expdp\/impdp with the remap_schema parameter, the password of the created user on the target database will not be a valid one.<\/p>\n<p>This because on Oracle 10g the password hash is calculated using the &#8220;username&#8221; as a seed. When you import a user with impdp, the password hash is not recalculated. So when the user changes (by the remap_schema parameter), the new schema password will not work.<\/p>\n<p>Clean environment: <\/p>\n<pre>SQL&gt; select username, password\nfrom dba_users&nbsp;\nwhere username='T1';\nno rows selected\n<\/pre>\n<p>\nCreate user T1 with simple password&#8230;<br \/>\n<\/p>\n<pre>SQL&gt; grant create session to t1 identified by t1;\nGrant succeeded.\n<\/pre>\n<p>\nCheck password hash_values<br \/>\n<\/p>\n<pre>SQL&gt; select username, password&nbsp;\nfrom dba_users&nbsp;\nwhere username='T1';\nUSERNAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PASSWORD\n------------------------------ ------------------------------\nT1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2A6EC3E5F234DF52\n<\/pre>\n<p>\nWe can connect:<br \/>\n<\/p>\n<pre>SQL&gt; connect t1\/t1\nConnected.\n<\/pre>\n<p>\nRun the export&#8230;<br \/>\n<\/p>\n<pre>$expdp schemas=t1\nExport: Release 10.2.0.4.0 - 64bit Production on Thursday, 19 April, 2012 11:16:30\nCopyright (c) 2003, 2007, Oracle.&nbsp; All rights reserved.\nUsername: \/ as sysdba\n\nConnected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production\nWith the Partitioning, OLAP, Data Mining and Real Application Testing options\nStarting \"SYS\".\"SYS_EXPORT_SCHEMA_01\":&nbsp; \/******** AS SYSDBA schemas=t1\n...\n\nJob \"SYS\".\"SYS_EXPORT_SCHEMA_01\" successfully completed at 11:17:00\n<\/pre>\n<p>\nAnd import with remap_schema:<br \/>\n<\/p>\n<pre>$impdp remap_schema=t1:t2\nImport: Release 10.2.0.4.0 - 64bit Production on Thursday, 19 April, 2012 11:18:30\nCopyright (c) 2003, 2007, Oracle.&nbsp; All rights reserved.\nUsername: \/ as sysdba\nConnected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production\nWith the Partitioning, OLAP, Data Mining and Real Application Testing options\nMaster table \"SYS\".\"SYS_IMPORT_FULL_01\" successfully loaded\/unloaded\nStarting \"SYS\".\"SYS_IMPORT_FULL_01\":&nbsp; \/******** AS SYSDBA remap_schema=t1:t2\nProcessing object type SCHEMA_EXPORT\/USER\nProcessing object type SCHEMA_EXPORT\/SYSTEM_GRANT\nProcessing object type SCHEMA_EXPORT\/DEFAULT_ROLE\nProcessing object type SCHEMA_EXPORT\/PRE_SCHEMA\/PROCACT_SCHEMA\nJob \"SYS\".\"SYS_IMPORT_FULL_01\" successfully completed at 11:18:35\n<\/pre>\n<p>\nWe see now that the password hash of the two users is the same:<br \/>\n<\/p>\n<pre>SQL&gt; select username, password from dba_users where username in ('T1','T2');\nUSERNAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PASSWORD\n------------------------------ ------------------------------\nT1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2A6EC3E5F234DF52\nT2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2A6EC3E5F234DF52\n\n<\/pre>\n<p>\nBut connecting with the original password does not work:<br \/>\n<\/p>\n<pre>SQL&gt; connect t2\/t1\nERROR:\nORA-01017: invalid username\/password; logon denied<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Something that is quite logical after you think about, but surprises you at first. When you do expdp\/impdp with the remap_schema parameter, the password of the created user on the target database will not be a valid one. This because on Oracle 10g the password hash is calculated using the &#8220;username&#8221; as a seed. When [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,6,8,9],"tags":[],"class_list":{"0":"post-18","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-datapump","7":"category-oracle","8":"category-oracle-10g","9":"category-security","10":"czr-hentry"},"_links":{"self":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":1,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":162,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/posts\/18\/revisions\/162"}],"wp:attachment":[{"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anjo.pt\/keyword-oracle\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}