Hi,
You can try following code.
Using pc = New PrincipalContext(ContextType.Domain, "domain.lan", username, password)
If pc.ValidateCredentials(username, password) Then
Try
Using searcher = New PrincipalSearcher(New UserPrincipal(pc))
searcher.QueryFilter.SamAccountName = username
Dim u As Principal = searcher.FindOne()
End Using
Catch generatedExceptionName As Exception
Return "no rights to work on ad"
End Try
Else
Return "user cannot login"
End If
End Using
Hope this will help you.
thanks