1. 程式人生 > >oracle使用者登入的3種認證方式

oracle使用者登入的3種認證方式

url:http://www.cnblogs.com/ivictor/p/4213823.html

Oracle對於普通賬戶和超級管理員(指sysdba和sysoper)的認證機制不一樣,前者是通過資料字典,後者主要是通過作業系統驗證和密碼檔案驗證。因此一般提到作業系統認證或密碼檔案認證,針對的都是超級管理員的認證。

作業系統認證

對於作業系統認證,其實蠻簡單的,只需要將該使用者新增到dba(針對sysdba許可權)或oper(針對sysoper許可權)組中,就可以使用 "sqlplus  / as sysdba"方式登陸

在Linux環境下,可通過以下命令新增屬組:usermod -g dba test  -->>test是使用者名稱

能否使用作業系統身份認證,取決於$ORACLE_HOME/network/admin/sqlnet.ora中SQLNET.AUTHENTICATION_SERVICES的取值。

      SQLNET.AUTHENTICATION_SERVICES = none | all | ntf(windows)

      none : 表示關閉作業系統認證,只能密碼認證。

      all : 作業系統認證和密碼認證均可。

      nts : 用於windows平臺。

      當 SQLNET.AUTHENTICATION_SERVICES = none時,會報以下錯誤:

[[email protected]
admin]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 9 23:14:18 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. ERROR: ORA-01017: invalid username/password; logon denied

     若用密碼登陸則沒有問題

複製程式碼
[[email protected] admin]$ sqlplus sys/oracle as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 9 23:17:31 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> 
複製程式碼

密碼檔案認證

這種方式在實際環境中較為普遍,利用的是orapwd工具建立密碼檔案。

在密碼檔案認證中,有一個引數十分重要:remote_login_passwordfile,該引數有三個值,預設為exclusive

none----不使用密碼檔案認證
exclusive---需要密碼檔案認證 自己獨佔使用
shared ---需要密碼檔案認證 不同例項dba使用者可以共享密碼檔案

密碼檔案的預設位置為:$ORACLE_HOME/dbs

密碼檔案的查詢順序:orapw<sid> -->  orapw  --> Failure

所以在建立密碼檔案時filename只能為orapw<sid>或者orapw

外部認證(External Authentication)

若對使用者採用外部認證,則只有使用者的賬號由Oracle管理,密碼和使用者登入的認證則通過外部服務來管理。外部認證常見的有作業系統認證和網路認證。

外部認證之作業系統身份驗證

此技術使用與作業系統使用者同樣的名稱建立Oracle使用者,但前面加上了os_authent_prefix引數指定的字串,預設為ops$,下面我們來看看官檔對該引數的說明:

OS_AUTHENT_PREFIX specifies a prefix that Oracle uses to authenticate users attempting to connect to the server. Oracle concatenates the value of this parameter to the beginning of the user's operating system account name. When a connection request is attempted, Oracle compares the prefixed username with Oracle usernames in the database.

The default value of this parameter is OPS$ for backward compatibility with previous versions. However, you might prefer to set the prefix value to "" (a null string), thereby eliminating the addition of any prefix to operating system account names.

可見,用ops$只是為了向前相容。

下面,我們來實驗一下。

一、建立作業系統使用者

     [[email protected] ~]# useradd test

二、建立Oracle使用者並授予相應的許可權

     SQL> create user ops$test identified externally;

     SQL> grant create session to ops$test;

三、用test使用者登入資料庫

[[email protected] ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

    報以上錯誤,根據提示,我們為ORACLE_HOME設定相應的值

    在/home/test/.bash_profile中新增如下值:   

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1

    重新用test使用者登入資料庫

[[email protected] ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /
SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 10 01:14:53 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name: 

    又報TNS:net service name is incorrectly specified錯誤。

    懷疑沒有指定相應的SID,在/home/test/.bash_profile中新增如下值:

export ORACLE_SID=orcl

    重新用test使用者登入    

複製程式碼
[[email protected] ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /
SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 10 01:18:22 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> show user
USER is "OPS$TEST"
複製程式碼

    終於成功登入!

這個是在本地環境下的作業系統認證,即test與oracle資料庫在同一個主機上。

倘若不在同一個主機上,必須將remote_os_authent設定為TRUE。

外部認證之網路認證

Network authentication is performed using Oracle Advanced Security, which can be configured to use a third-party service such as Kerberos. If you are using Oracle Advanced Security as your only external authentication service, then the REMOTE_OS_AUTHENT parameter setting is irrelevant, becauseOracle Advanced Security only allows secure connections.

關於外部認證,我們來看看官方文件的說明

1> More choices of authentication mechanism are available, such as smart cards, fingerprints, Kerberos, or the operating system.
2> Many network authentication services, such as Kerberos support single sign-on, enabling users to have fewer passwords to remember.
3> If you are already using some external mechanism for authentication, such as one of those listed earlier, then there may be less administrative overhead to use that mechanism with the database as well.

Easy Connect

    [[email protected] ~]$ sqlplus system/[email protected]:1521/sz.being.com  

    其中,192.168.2.12是資料庫所在主機的IP,1521是資料庫所在主機的監聽埠,sz.being.com是資料庫提供的服務名

總結:

1> 作業系統認證優先於密碼檔案認證。譬如在oracle使用者下,我用sqlplus 123/456 as sysdba也可登入到資料庫中,即便123不是資料庫使用者。

2> 與Oracle資料庫在同一主機上的使用者,只需要知道使用者和密碼即可登入資料庫,譬如在test1使用者下,執行sqlplus scott/tiger和sqlplus sys/oracle as sysdba均可登入到資料庫,前者是通過資料字典進行驗證,後者通過密碼檔案進行驗證。

參考文件:

相關推薦

oracle使用者登入3認證方式

url:http://www.cnblogs.com/ivictor/p/4213823.htmlOracle對於普通賬戶和超級管理員(指sysdba和sysoper)的認證機制不一樣,前者是通過資料字典,後者主要是通過作業系統驗證和密碼檔案驗證。因此一般提到作業系統認證或密

asp.net提供的3認證方式

asp.net提供了3種認證方式: windows身份驗證, Forms驗證和Passport驗證. windows身份驗證: IIS根據應用程式的設定執行身份驗證.要使用這種驗證方式,在IIS中必須禁用匿名訪問. Forms驗證:用Cookie來儲存使用者憑證,

struts2封裝客戶端請求數據(3封裝方式

空指針異常 必須 nis png pri pan this drive .cn 長話短說,直接進入主題. 1.屬性驅動 action的屬性名稱必須和jsp輸入項的name屬性保持一致; 必須要在action類中提供該屬性的set方法,但有時候會出錯,為了保險起見,我們把g

LVS原理詳解(3工作方式8調度算法)--老男孩

工作流程圖 nfs服務器 靈活 做成 靈活性 www. 24小時 必須 其他 一、LVS原理詳解(4種工作方式8種調度算法) 集群簡介 集群就是一組獨立的計算機,協同工作,對外提供服務。對客戶端來說像是一臺服務器提供服務。 LVS在企業架構中的位置:

單例模式的 3 實現方式

會有 static AI cache 第一次用 AS volatile 補充 機制 1. 在單例類被加載的時候實例化,這種實現方式被稱為餓漢模式。 1 public class Singleton { 2 private static Singleton in

多線程基礎一之(線程的3實現方式

font dem cep urn led ring ble new t println 實現線程的三種方式: (1)繼承Thread類,重寫Run方法  class MyThreadDemo extends Thread { @Override publi

ssh兩認證方式的原理介紹

SSH是一種加密的網路傳輸協議,可在不安全的網路中為網路服務提供安全的傳輸環境。SSH通過在網路中建立安全隧道來實現SSH客戶端與伺服器之間的連線。雖然任何網路服務都可以通過SSH實現安全傳輸,SSH最常見的用途是遠端登入系統,人們通常利用SSH來傳輸命令列介面和遠端執行命令。ssh 協議互

(四)Hive的連線3連線方式

(四)Hive的連線3種連線方式   目錄 一、CLI連線 二、HiveServer2/beeline 1、修改 hadoop 叢集的 hdfs-site.xml 配置檔案 2、修改 hadoop 叢集的 core-site.xml

C#: 執行緒Thread的3使用方式

1.直接看程式碼 using System; using System.Threading; using System.Timers; using System.Windows.Forms; namespace WindowsFormsApp13 { public partial cl

java執行緒的3建立方式

Java使用Thread類代表執行緒,所有的執行緒物件都必須是Thread類或其子類的例項。Java可以用三種方式來建立執行緒,如下所示: 1)繼承Thread類建立執行緒 2)實現Runnable介面建立執行緒 3)實現Callable介面建立執行緒 4)通過執行緒池的方式建立(這

laravel5 3驗證方式

做專案的時候,大家都知道要驗證。那麼今天我就說說laravel的3種驗證方式: 1、手動建立驗證器:該驗證規則就寫到控制器裡面,造成控制器程式碼太多,個人認為不美觀; 2、表單請求驗證:該方法驗證,相信大家常用。在此之前,我都是用表單驗證,前兩種驗證方式在laravel文

分治法:快速排序,3劃分方式,隨機化快排,快排快,還是歸併排序快?

快速排序不同於之前瞭解的分治,他是通過一系列操作劃分得到子問題,不同之前的劃分子問題很簡單,劃分子問題的過程也是解決問題的過程 我們通常劃分子問題儘量保持均衡,而快排缺無法保持均衡 快排第一種劃分子問題實現方式,左右填空的雙指標方式 def partition_1(arr,low

linux Socket close()函式 的3返回方式

Socket close()函式 的3種返回方式 socket close()返回的方式通過 setsockopt :SO_LINGER 選項設定 此選項指定函式close對面向連線的協議如何操作(如TCP),核心預設close操作是立即返回,如果有資料殘留在套介面緩衝區中則系統將試

【已驗證】android studio 打包報 MissingTranslation 的3解決方式

Android studio打包生成android apk的時候遇到了編譯問題,明明沒有想要做英文翻譯,但是AS生成apk的時候自己走了translate in english的路線。幾個string.xml檔案報錯 string value is not translate

DMA和UART的深刻認識--串列埠接收的3工作方式(附STM32F4程式碼)

可能會遇到的問題:1.能實現接收但不傳送 注意是否是識別函數出錯2.DMA單次傳輸模式要求再初始化,否者出現第二次中斷不執行。使用迴圈模式出現的問題是要結合配置公式:3.DMA再次初始化不完全,會出現接收一次成功,再來一次不行。第三次能接收的問題4.串列埠除錯連續點選的次數太

Java連線Oracle資料庫的三連線方式

背景: 這兩天在學習Oracle資料庫,這裡就總結下自己上課所學的知識,同時記錄下來,方便整理當天所學下的知識,也同時方便日後自己查詢。 SQL語句的話,這裡我就不多講了,感覺和其他的資料庫(MySQL、SQL Server)都是類似,區別不大。 今天在這

懶載入的3實現方式

優勢 效能收益:瀏覽器載入圖片、decode、渲染都需要耗費資源,懶載入能節約效能消耗,縮短onload事件時間。 節約頻寬:這個不需要解釋。 通常,我們在html中展示圖片,會有兩種方式: img 標籤 css background-image img的懶載入實現 im

Oauth三認證方式

1.資源所有者密碼憑據許可。Resource Owner Password Credentials Grant 2.隱式許可。Implicit Grant 3.授權碼許可。Authorization Code Grant cookie是不能跨域的 共享session庫 統一認證中心 一個

oracle 資料庫中幾連線方式執行過程(nested loop、hash join、sort order join)

簡單介紹了一下oracle 各種連線方式的執行過程,虛擬碼內容來源於pro oracle sql。 nested loop: select empno, ename, dname, loc fro

ajax的3請求方式

                        &nbs