Problema con la Seguridad
Publicado por Carlos (5 intervenciones) el 22/01/2005 23:05:12
Public Function IsAuthenticated(ByVal domain As String, ByVal user As String, ByVal pass As String) As Boolean
Dim domusr as string
domusr = domain & "\" & user
Dim entry As DirectoryEntry = New DirectoryEntry(_path & Domain, domusr, pass, AuthenticationTypes.Secure)
Try
Dim obj As Object = entry.NativeObject
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(SAMAccountName=" & user & ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
Return False
End If
_path = result.Path
_filterAttribute = CType(result.Properties("cn")(0), String)
Catch ex As Exception
Throw New Exception("Error en la autenticación. " & ex.Message)
End Try
Return True
End Function
Dim domusr as string
domusr = domain & "\" & user
Dim entry As DirectoryEntry = New DirectoryEntry(_path & Domain, domusr, pass, AuthenticationTypes.Secure)
Try
Dim obj As Object = entry.NativeObject
Dim search As DirectorySearcher = New DirectorySearcher(entry)
search.Filter = "(SAMAccountName=" & user & ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()
If (result Is Nothing) Then
Return False
End If
_path = result.Path
_filterAttribute = CType(result.Properties("cn")(0), String)
Catch ex As Exception
Throw New Exception("Error en la autenticación. " & ex.Message)
End Try
Return True
End Function
Valora esta pregunta


0