Change code to work with OLEDB

G

Guest

Can someone please tell me how I edit this code so it works with an OleDB...

Thanks



Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)
' Fires upon attempting to authenticate the use
If Request.IsAuthenticated Then
'Determine this user's roles
Dim reader As OleDbDataReader
reader =
SqlHelper.ExecuteReader(ConfigurationSettings.AppSettings("strConn"),
CommandType.StoredProcedure, "rolesForUser", New OleDbParameter("@Username",
User.Identity.Name))

' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(reader("Name"))
Loop
reader.Close()

'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArray(GetType(String))

'Add the roles to the User Principal
HttpContext.Current.User = _
New
System.Security.Principal.GenericPrincipal(User.Identity, roleListArray)
End If
End Sub
 
G

Guest

There is no error as such!

You just can't use SQLHelper object with OleDB connection So I was wondering
how else it could be done!

Here is what I'm working on!

Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)
' Fires upon attempting to authenticate the use
If Request.IsAuthenticated Then

Dim objConn
Dim cmd As OleDbCommand
Dim strSQL As String

strSQL = "SELECT group FROM persons = @Username"

objConn = New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
cmd = New OleDbCommand(strSQL, objConn)

'Determine this user's roles
Dim reader As OleDbDataReader
cmd.Parameters.Add("@Username", User.Identity.Name)
reader = cmd.ExecuteReader


' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(reader("Name"))
Loop
reader.Close()

'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArray(GetType(String))

'Add the roles to the User Principal
HttpContext.Current.User = _
New
System.Security.Principal.GenericPrincipal(User.Identity, roleListArray)
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top