1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      VB.NET如何驗證LDAP用戶身份

      這篇文章主要為大家展示了“VB.NET如何驗證LDAP用戶身份”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“VB.NET如何驗證LDAP用戶身份”這篇文章吧。

      成都創(chuàng)新互聯(lián)公司專注于宿松企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,商城網(wǎng)站制作。宿松網(wǎng)站建設(shè)公司,為宿松等地區(qū)提供建站服務(wù)。全流程按需開發(fā),專業(yè)設(shè)計,全程項目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)

      首先,我要講的LDAP不是微軟的Active Directory目錄服務(wù),而是運行在SUN One上面的目錄服務(wù)。

      請看VB.NET驗證LDAP用戶身份的代碼(部分敏感信息刪節(jié)):

      1. Private Sub btnTest_Click()Sub btnTest_
        Click(ByVal sender As System.Object, 
        ByVal e As System.EventArgs) Handles 
        btnTest.Click  

      2. Dim LoginName As String = txtUser.Text  

      3. Dim LoginPwd As String = txtPwd.Text  

      4. If LoginPwd = "" Then  

      5. txtResult.Text = "* Password can not be blank." 

      6. Exit Sub  

      7. End If  

      8. Dim myDirectorySearcher As DirectorySearcher  

      9. Dim mySearchResult As SearchResult  

      10. Dim myDirectoryEntry As DirectoryEntry  

      11. Dim UserName As String  

      12. txtResult.Text = "" 

      13. Try  

      14. If myDirectoryEntry.Exists("LDAP:
        //ldapserver.com/uid=" & LoginName & ",
        ou=people,ou=intranet,dc=yourdomainname,
        dc=com") Then  

      15. Try  

      16. myDirectoryEntry = New DirectoryEntry
        ("LDAP://ldapserver.com/ou=people,
        ou=intranet,dc=yourdomainname,dc=com", 
        "uid=" & LoginName & ",ou=people,ou=intranet,
        dc=yourdomainname,dc=com", LoginPwd, 
        AuthenticationTypes.ServerBind)  

      17. myDirectorySearcher = New Directory
        Searcher(myDirectoryEntry)  

      18. myDirectorySearcher.Filter = "
        (uid=" & txtUser.Text & ")"  

      19. myDirectorySearcher.PropertiesToLoad.
        Add("DisplayLastName")  

      20. myDirectorySearcher.PropertiesToLoad.
        Add("DisplayFirstName")  

      21. mySearchResult = myDirectorySearcher.FindOne  

      22. If mySearchResult Is Nothing Then  

      23. txtResult.Text += "* Login failed."  

      24. Else  

      25. txtResult.Text += ">>> Login passed!" & vbCrLf  

      26. UserName = mySearchResult.GetDirectory
        Entry().Properties("DisplayFirstName").
        Value & " " & mySearchResult.GetDirectory
        Entry().Properties("DisplayLastName").Value  

      27. txtResult.Text += UserName & vbCrLf  

      28. End If  

      29. Catch ex As Exception  

      30. txtResult.Text += "* Login failed." & 
        vbCrLf & ex.Message  

      31. End Try  

      32. Else  

      33. txtResult.Text += "* Invalid user login name."  

      34. End If  

      35. Catch ex As Exception  

      36. txtResult.Text += "* Can not access the 
        LDAP server." & vbCrLf & ex.Message  

      37. End Try  

      38. End Sub 

      這里要說明一下:

      1、必須檢驗密碼不能為空,否則會造成驗證有誤,即空密碼能通過驗證,不知道為什么。

      2、LDAP://......這最前面的四個字母LDAP必須大寫!否則報未知錯誤,不知道為什么,還得我走了一段彎路。

      3、ldapserver.com需要替換成LDAP服務(wù)器的地址。

      4、LDAP://......地址后面的參數(shù),要根據(jù)你要訪問的LDAP的設(shè)置而定。

      5、如果密碼不對,會引發(fā)異常,所以我在異常處理中捕獲,但是不知道這樣是否正確。

      6、If mySearchResult Is Nothing Then 這句我覺得是廢話,好像怎么也不會為True,如果密碼不對,會引發(fā)異常的,但是不放心還是加上這句,可能是我的判斷邏輯有問題。

      以上是“VB.NET如何驗證LDAP用戶身份”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


      網(wǎng)頁名稱:VB.NET如何驗證LDAP用戶身份
      路徑分享:http://ef60e0e.cn/article/peehch.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        德昌县| 集安市| 双鸭山市| 民勤县| 平潭县| 金湖县| 华安县| 上林县| 辽阳市| 宜阳县| 闽侯县| 长武县| 丰原市| 南漳县| 凌源市| 江陵县| 霸州市| 旬阳县| 婺源县| 浦县| 布拖县| 吴忠市| 育儿| 中方县| 巴彦县| 临邑县| 锦屏县| 喀喇| 邻水| 诏安县| 资阳市| 晋城| 资中县| 饶阳县| 望都县| 石家庄市| 静乐县| 淮滨县| 府谷县| 五指山市| 玉溪市|