3

我的問題在於如何處理安全問題以及適當的模擬實現,這將從客戶端計算機工作並正確地向我的IIS服務器進行身份驗證,該服務器會將仍然有效的模擬憑證和LDAP請求一起傳遞。模擬有委派或Kerberos上有一個以上的跳躍?完全丟失

我的系統是運行在我公司Intranet上的一個獨立服務器,它承載域控制器,LDAP服務器等,並使用Kerberos協議。

  • 系統信息:IIS7使用Windows身份驗證並模擬在Windows 7 64位
  • 網絡信息:IIS 6,LDAP,Kerberos的

這裏是我的VB.NET方法。

Protected FirstName, LastName, EMail As String 
Protected Sub Lookup(ByVal UserName As String) 
    UserName = Trim(UserName) 
    UserName = Replace(UserName, "\", "/") 
    UserName = Right(UserName, Len(UserName) - InStr(1, UserName, "/")) 

    Using (Hosting.HostingEnvironment.Impersonate) 'ADDED 
     Dim directoryEntry As New DirectoryEntry("LDAP://dl/DC=dl,DC=net") 
     'directoryEntry.AuthenticationType = AuthenticationTypes.Delegation 'REMOVED 

     Dim ds As New DirectorySearcher(directoryEntry) 
     Dim r As SearchResult 
     Try 
      ds.PropertiesToLoad.Add("givenName") 'First Name 
      ds.PropertiesToLoad.Add("sn")  'Last Name 
      ds.PropertiesToLoad.Add("mail")  'Email 

      ds.Filter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=" & UserName & "))" 
      r = ds.FindOne 'Query LDAP; find record with UserName. 

      'Populates all the variables retrieved from LDAP. 
      FirstName = If(r.Properties.Contains("givenName"), Trim(r.Properties("givenName").Item(0)), "") 
      LastName = If(r.Properties.Contains("sn"), Trim(r.Properties("sn").Item(0)), "") 
      If IsNothing(r.Properties.Contains("mail")) Then 
       EMail = If(r.Properties.Contains("userPrincipalName"), Trim(r.Properties("userPrincipalName").Item(0)), "") 
      Else 
       EMail = If(r.Properties.Contains("mail"), Trim(r.Properties("mail").Item(0)), "") 
      End If 
      EMail = EMail.ToLower 
     Catch ex As Exception 
      'Error Logging to Database Here 
     End Try 
    End Using 
End Sub 

請提出任何問題以獲取所需的信息以幫助我。我一直在研究這個問題好幾周,看起來Impersonation有這麼多的變數,我很容易迷路。我只是無法弄清楚如何在我的代碼中實現這個功能......我對.NET仍然相當陌生:(

+0

答案在於Brian的建議,其實我的服務器沒有得到授權的域控制員的授權,一旦我的IT部門得到了改變,並添加了我的更新後的代碼中提到的'Using'語句,一切都運行良好:) – Chiramisu 2012-02-16 17:51:00

回答

2

你不需要配置AuthenticationType就可以工作。以確保託管上述代碼的服務帳戶(或計算機帳戶,如果網絡服務)被允許在您的環境中的所有DC上委託給LDAP服務

+0

非常感謝!我不敢相信這是這樣的,但我對AD和IT管理員幾乎一無所知。非常感謝你在無數次的挫折和研究之後指引我朝着正確的方向前進。 ^。^ – Chiramisu 2012-02-16 17:52:59

相關問題