2012-07-24 12 views

回答

1

是的,它是強制使用Windows身份驗證文件流。 處理它的最好的事情就是模仿它。

聲明類

[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] 
     public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwlogonType, int dwlogonProvider, out SafeTokenHandle phtoken); 

[DllImport("kernel32.dll", CharSet = CharSet.Auto)] 
     public static extern bool CloseHandle(IntPtr handle); 

然後在方法內部下面的方法:

public void method() 
{ 

    WindowsImpersonationContext context = null; 
    SafeTokenHandle safeTokenHandle; 

    bool returnValue = LogonUser(connString[0], connString[1], connString[2], Convert.ToInt32(connString[3]), Convert.ToInt32(connString[4]), out safeTokenHandle); 

    WindowsIdentity windowsIdentity = new WindowsIdentity(safeTokenHandle.DangerousGetHandle()); 

    context = windowsIdentity.Impersonate(); 

    //Make some operations 

    context.undo(); 

} 
0

我想知道C#中的文件流是否使用SQL Server身份驗證。

取決於您認爲FileStream是。通過SQL的FileStream訪問使用SQL連接使用。通過Windows的FileStream - 顯而易見 - 必須使用Windows身份驗證。

是否可以通過使用 userid和password在windows身份驗證中使用filestream連接到數據庫?

是否可以使用用戶名和密碼連接到Windows共享?是。只要thos ae是Windows用戶的用戶名和密碼。

+0

當訪問SQL-Server's FILESTREAM您的SQL-auth的僅用於檢查我們的桌子和現場許可。 definitv文件訪問由sql服務器服務完成,並具有正在運行的權限,例如本地服務。這意味着只有此用戶/服務帳戶需要文件流容器 – 2012-07-24 10:07:19

+0

@ marc.d半知識上的NTFS權限。您知道,可以將FileStream公開爲網絡共享。然後通過SQL獲取特定文件的路徑,以便您可以直接訪問它。這非常棒,例如對於一個文檔庫(Word可以這麼說,可以在不知道任何異常SQL的情況下讀取文件)以及許多其他場景,並且在許多情況下,我會看到主要的訪問形式 - 您似乎完全不知道。 http://www.mssqltips.com/sqlservertip/1838/different-ways-to-enable-filestream-feature-of-sql-server-2008/,http://msdn.microsoft.com/de-de/library /bb895239.aspx – TomTom 2012-07-24 10:43:18

+0

是否可以使用SQL Server身份驗證? – user1400915 2012-07-25 08:24:34