detailsview authenticate user before insert
Posted on 2008-11-05
I want to authenticate a user before allowing them to insert a new record. I have a funtion to check the username and password are correct which returns true or false.
The details view has four fields, projectnumber, customer, startdate, and user. user is the user id of the authenticated user.
My first question is where do I ask for the password, can I add a password field to the details view or do I need some other mechanism?
Secondly I know there is an ItemInserting for the details view or an inserting event for the sqldatasource, which is best to use and how do I allow the insert if authenticated or block it if not?
Function AuthenticateUser(ByVal path As String, ByVal user As String, ByVal pass As String) As Boolean
Dim dirEntry As New DirectoryEntry(path, user, pass)
Dim nat As Object
'if the NativeObject can be created using those credentials
'then they are valid.
nat = dirEntry.NativeObject