 |
|
สอบถามเรื่อง User Authentication Active Directory ถ้ามีการเช็คหลายPATH ไม่ทราบว่าต้องเช็คยังไงหรอครับ |
|
 |
|
|
 |
 |
|
ทำหลายรอบครับ 
|
 |
 |
 |
 |
Date :
2015-12-23 11:58:47 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2015-12-23 16:49:58 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันคืออะไรหรอครับพี่ TOR_CHEMISTRY ผมยังไม่ค่อยเก่งเท่าไหร่อะครับ
ตอนแรกกะจะ เอาไปอยู่ใน IF ที่มัน false อะครับผม แต่ถ้าทำ มันจะ query ช้าไหมครับ
ถ้าเป็นแบบข้างล่าง ผมจะเปลี่ยนที่ยังไงหรอครับ
Code (VB.NET)
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
public Notinheritable Class PathActive
Dim initLDAPPath As String = "DC=opsd,DC=net"
Dim initLDAPServer As String = "10.0.4.32"
Dim initShortDomainName As String = "OPSD"
end class
public Notinheritable Class PathActive1
Dim initLDAPPath1 As String = "DC=test,DC=net"
Dim initLDAPServer1 As String = "1.0.0.33"
Dim initShortDomainName1 As String = "test"
end class
strCommu = "LDAP://" & initLDAPServer & "/" & initLDAPPath
DomainAndUsername = initShortDomainName & "\" & txtUser.Text
Dim entry As New DirectoryEntry(strCommu, DomainAndUsername, txtPwd.Text)
Dim obj As Object
Try
obj = entry.NativeObject
Dim search As New DirectorySearcher(entry)
Dim result As SearchResult
search.Filter = "(SAMAccountName=" + txtUser.Text + ")"
search.PropertiesToLoad.Add("cn")
result = search.FindOne()
If result Is Nothing Then
flgLogin = False
strErrMsg = "Please check user/password"
Else
flgLogin = True
End If
Catch ex As Exception
flgLogin = False
strErrMsg = "Please check user/password"
End Try
IF flgLogin = True
Me.lbDisplay.Text = "Welcome " & txtUser.Text
Else
Me.lbDisplay.Text = strErrMsg
End IF
End Sub
|
ประวัติการแก้ไข 2015-12-23 21:40:07 2015-12-23 21:47:11 2015-12-23 21:49:46
 |
 |
 |
 |
Date :
2015-12-23 21:38:23 |
By :
omyam001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หรือต้องแบบนี้ครับ
Code (VB.NET)
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim initLDAPPath As String = "DC=opsd,DC=net"
Dim initLDAPServer As String = "10.0.4.32"
Dim initShortDomainName As String = "OPSD"
Dim initLDAPPath1 As String = "DC=test,DC=net"
Dim initLDAPServer1 As String = "1.0.0.33"
Dim initShortDomainName1 As String = "test"
strCommu = "LDAP://" & initLDAPServer & "/" & initLDAPPath
DomainAndUsername = initShortDomainName & "\" & txtUser.Text
Dim entry As New DirectoryEntry(strCommu, DomainAndUsername, txtPwd.Text)
Dim obj As Object
Try
obj = entry.NativeObject
Dim search As New DirectorySearcher(entry)
Dim result As SearchResult
search.Filter = "(SAMAccountName=" + txtUser.Text + ")"
search.PropertiesToLoad.Add("cn")
result = search.FindOne()
If result Is Nothing Then
flgLogin = False
strErrMsg = "Please check user/password" ' เอามาไว้ข้างในแบบนี้เลยหรอครับ
Dim initLDAPPath1 As String = "DC=test,DC=net"
Dim initLDAPServer1 As String = "1.0.0.33"
Dim initShortDomainName1 As String = "test"
strCommu = "LDAP://" & initLDAPServer & "/" & initLDAPPath
DomainAndUsername = initShortDomainName & "\" & txtUser.Text
Dim entry As New DirectoryEntry(strCommu, DomainAndUsername, txtPwd.Text)
Dim obj As Object
Try
obj = entry.NativeObject
Dim search As New DirectorySearcher(entry)
Dim result As SearchResult
search.Filter = "(SAMAccountName=" + txtUser.Text + ")"
search.PropertiesToLoad.Add("cn")
result = search.FindOne()
If result Is Nothing Then
flgLogin = False
strErrMsg = "Please check user/password"
Else
flgLogin = True
End If
Catch ex As Exception
flgLogin = False
strErrMsg = "Please check user/password"
End Try
IF flgLogin = True
Me.lbDisplay.Text = "Welcome " & txtUser.Text
Else
Me.lbDisplay.Text = strErrMsg
End IF
Else
flgLogin = True
End If
Catch ex As Exception
flgLogin = False
strErrMsg = "Please check user/password"
End Try
IF flgLogin = True
Me.lbDisplay.Text = "Welcome " & txtUser.Text
Else
Me.lbDisplay.Text = strErrMsg
End IF
End Sub
|
 |
 |
 |
 |
Date :
2015-12-23 21:51:11 |
By :
omyam001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยกตัวอย่างเพื่อเอาเอา class มาทำเป็น list ครับ
สร้าง class แยกออกมา
Code (VB.NET)
Public NotInheritable Class PathActive
Public Shared initLDAPPath As String = "DC=opsd,DC=net"
Public Shared initLDAPServer As String = "10.0.4.32"
Public Shared initShortDomainName As String = "OPSD"
Public Shared initLDAPPath1 As String = "DC=opsd,DC=net"
Public Shared initLDAPServer1 As String = "10.0.4.1"
Public Shared initShortDomainName1 As String = "test1"
Public Shared initLDAPPath2 As String = "DC=opsd,DC=net"
Public Shared initLDAPServer2 As String = "10.0.4.2"
Public Shared initShortDomainName3 As String = "test2"
End Class
Code (VB.NET)
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
strCommu = "LDAP://" & PathActive.initLDAPServer & "/" & PathActive.initLDAPPath
DomainAndUsername = PathActive.initShortDomainName & "\" & txtUser.Text
Dim entry As New DirectoryEntry(strCommu, DomainAndUsername, txtPwd.Text)
End Sub
ประมาณนี้ครับ
|
 |
 |
 |
 |
Date :
2015-12-25 08:39:15 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วตรงไหนที่ มัน เปรียบเทียบกันหรอครับ ยังมองภาพไม่เลยงับผม
ของผม แค่ initLDAPServer เปลี่ยนเท่านั้นเองครับ นอกนั้นเหมือนเดิมหมด
ยังติดตรง initLDAPServer initLDAPServer1 จะเปรียบเทียบยังไงหรอครับ
|
 |
 |
 |
 |
Date :
2015-12-25 17:36:05 |
By :
omyam001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|