| | |
Create Windows Authentication
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
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:
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.
Your select statement is fine, what you need to do is use the results of the query:
VB.NET Syntax (Toggle Plain Text)
<% 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() If rsGET.BOF OR rsGET.EOF Then ' NO MATCHING RECORDS FOUND CODE - DON'T DISPLAY ANYTHING Else %> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><%=(rsGET.Fields.Item("PERMISSION_BUTTON_ID").Value)%></td> </tr> </table> <% End If %> ' Other html code here <% ' Destroy and close the db connection rsGET.Close() Set rsGET = Nothing %>
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!
•
•
Join Date: Apr 2004
Posts: 11
Reputation:
Solved Threads: 0
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
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
![]() |
Similar Threads
- Changing a database from Windows Authentication to use Username and Password (C#)
- Windows Authentication with AD (ASP.NET)
- Getting windows authentication (Java)
Other Threads in the VB.NET Forum
- Previous Thread: connecting to autocad
- Next Thread: Can i do something international using which side of vb.net whether it is ado.net, we
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access account advanced application array arrays basic beginner browser button buttons center checkbox client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel fade filter forms generatetags gridview html images input intel internet listview map mobile monitor net number objects open panel pdf picturebox picturebox2 port position print printing problem read remove save searchvb.net select serial settings shutdown socket sorting sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter update user usercontol validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode year





