Create Windows Authentication

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2004
Posts: 20
Reputation: DVHost is an unknown quantity at this point 
Solved Threads: 0
DVHost's Avatar
DVHost DVHost is offline Offline
Newbie Poster

Re: Create Windows Authentication

 
0
  #11
Apr 22nd, 2004
It sounds like we are back to the second and fourth post in this thread. Now its time to bring them together

Your select statement is fine, what you need to do is use the results of the query:

  1. <%
  2. Dim rsGET
  3. Set rsGET = Server.CreateObject("ADODB.Recordset")
  4. rsGET.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\rkrishn3\\Desktop\\authentication.mdb"
  5. rsGET.Source = "Select PERMISSION_BUTTON_ID from ALC_SECURITY_PERMISSION where NT_LOGIN = '" + username + "' and ROLE_ID = 1"
  6. rsGET.CursorType = 0
  7. rsGET.CursorLocation = 2
  8. rsGET.LockType = 1
  9. rsGET.Open()
  10.  
  11. If rsGET.BOF OR rsGET.EOF Then
  12.  
  13. ' NO MATCHING RECORDS FOUND CODE - DON'T DISPLAY ANYTHING
  14.  
  15. Else
  16.  
  17. %>
  18. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  19. <tr>
  20. <td><%=(rsGET.Fields.Item("PERMISSION_BUTTON_ID").Value)%></td>
  21. </tr>
  22. </table>
  23. <% End If %>
  24.  
  25.  
  26. ' Other html code here
  27.  
  28. <%
  29. ' Destroy and close the db connection
  30.  
  31. rsGET.Close()
  32. Set rsGET = Nothing
  33. %>

I am not 100% sure how you go about displaying your controls via there ID's but the code: <%=(rsGET.Fields.Item("PERMISSION_BUTTON_ID").Value)%> will implement the contents of the data in the DB that matches the query.
The Big Dog, Bites Hard!
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 11
Reputation: Tellie is an unknown quantity at this point 
Solved Threads: 0
Tellie Tellie is offline Offline
Newbie Poster

Re: Create Windows Authentication

 
0
  #12
Apr 22nd, 2004
I have not used the recordset as there was some error that I was facing. Here is the code that I am working on:

Dim user As WindowsPrincipal = New WindowsPrincipal(WindowsIdentity.GetCurrent())

Dim username AsString

If (user IsNothing) Then

Response.Write("No User")

Else

username = user.Identity.Name

Response.Write("Username " + username)

EndIf

Dim connectionString AsString

connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\rkrishn3\\Desktop\\authentication.mdb"

Dim myConnection AsNew OleDbConnection(connectionString)

myConnection.Open()

Dim mySelectQuery AsString = "Select NT_LOGIN, ROLE_ID, APP_ID from ALC_SEC_ROLES where NT_LOGIN = '" + username + "' and ROLE_ID = 1 and APP_ID = 1"

Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter(mySelectQuery, myConnection)

Dim employeeData As DataSet = New DataSet

myAdapter.Fill(employeeData, "ALC_SEC_ROLES")

If (employeeData.Tables("ALC_SEC_ROLES").Rows.Count > 0) Then

Dim myQuery AsString = "Select PERMISSION_BUTTON_ID from ALC_SECURITY_PERMISSION where NT_LOGIN = '" + username + "' and ROLE_ID = 1"

Dim myAdap As OleDbDataAdapter = New OleDbDataAdapter(myQuery, myConnection)

Dim empData1 As DataSet = New DataSet

myAdap.Fill(empData1, "ALC_SECURITY_PERMISSION")

If (empData1.Tables("ALC_SECURITY_PERMISSION").Rows.Count > 0) Then

Button1.Visible = False

Button2.Visible = True

Button3.Visible = False

EndIf

EndIf

myConnection.Close()

myConnection = Nothing

EndSub

The error that I was getting while using the code:

Dim rsGET
Set rsGET = Server.CreateObject("ADODB.Recordset")
rsGET.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\rkrishn3\\Desktop\\authentication.mdb"
rsGET.Source = "Select PERMISSION_BUTTON_ID from ALC_SECURITY_PERMISSION where NT_LOGIN = '" + username + "' and ROLE_ID = 1"
rsGET.CursorType = 0
rsGET.CursorLocation = 2
rsGET.LockType = 1
rsGET.Open()

was for rsGET.CursorType = 0 stating that the value is out of scope or so, I do not remember the exact message
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC