Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change HTML menu option subject to permissions 1

Status
Not open for further replies.

jon24422531

Technical User
Jan 27, 2004
295
GB
Hi

We have an intranet that I am developing and I would like users to be presented with different menu options subject to their permissions.

We have a SQL table (Users) that lists all company personnel and in there is a field for permissions, the options of which are: SuperUser, StandardUser, NoAccess

The UserName is determined thus:
Code:
Dim objNTInfo
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetUserName = objNTInfo.UserName

The query is (after connection strings etc):
Code:
StrSQL = "select WorkLogPermissions from users where userid = ('" & objNTInfo.UserName & "')"
Set MyRSData = MyConn.Execute(strSQL2)

The Menu structure is:
Code:
<%if (RSData.fieldItem.value) = "SuperUser" then
%>
<li><a href="IT/ITIndex2.html"target = "CENTER">IT Dept</a>
<%else%>
<li><a href="UnderConstruction.html"target = "CENTER">N/A</a>
<%end if%>

and this is the error:
Microsoft VBScript compilation error '800a0400'

Expected statement

/navigate.asp, line 84

<%if (RSData.fieldItem.value) = "SuperUser" then
^


What am I missing? Is it not possible to use the fieldItem.value except when writing to a HTML table


Jonathan
 
Damber

Thanks for your reply. I can see the logic of what you say, but it still doesn't work. I shall do a little further playing around (if work doesn't interfere) and let you know how I get on.



Jonathan
 
Damber

Thanks for the reply.....

This is the code;
Code:
  <li><a href="#">Video Guides</a>
    <ul> 
      <li><a href="Billing2/Billing.html"target = "CENTER">Billing Queries</a></li>    
      <li><a href="FTWebDemo/FTWebDemo.html"target = "CENTER">Filetrak Web Demo</a></li> 
      <li><a href="FTWebBehindTheScenes/FTWebBehindTheScenes.html"target = "CENTER">FTWeb Behind The Scenes</a></li> 
    </ul>
  <li><a href="Scanning/ScanningIndex.html"target = "CENTER">Scanning</a>
<%if MyRSData.Fields("WorkLogPermissions") = "SuperUser" then%>
  <li><a href="IT/ITIndex2.html"target = "CENTER">IT Dept</a>
<%else%>
  <li><a href="UnderConstruction.html"target = "CENTER">N/A</a>
<%end if%>
  <li><a href="#">Other Stuff</a>
    <ul>

This is the error I get

error '80020009'

/navigate.asp, line 86




Jonathan
 

I assume by that you mean ADODB.Field error - that there is no current record.. therefore you can access the field data

Try checking for any records:

if MyRSData.EOF and MyRSData.BOF then
Respones.write ("No records")
end if

obviously you can do what you like as a result of the check, but this will at least help you debug and understand the issue.

=======================================
LessThanDot - The IT Community of the 21st Century

A smile is worth a thousand kind words. So smile, it's easy! :)
 
damber

I declared a variable called permissions and then used this code before the HTML menu structure:
Code:
set MyRSData = Server.CreateObject("ADODB.Recordset")
StrSQL2 = "select WorkLogPermissions from users where userid = ('" & objNTInfo.UserName & "')"
Set MyRSData = MyConn.Execute(strSQL2)
Permissions = MyRSData.GetRows(1,0)
set MyConn = Nothing
response.Write (Permissions(0,0))
and it gives the correct data (SuperUser) at the top of the page, so am I right in thinking that we are getting a record?

I also tried using the permissions variable:
Code:
<%if Permissions = SuperUser then%>
but that gave an error too.


Jonathan
 

I think you're confusing yourself here a little bit. GetRows returns an array from the recordset and is usually a much more efficient way of iterating through the values (as a replacement of the recordset).

You would access the array as you did in the first example.. the second example is trying to compare a non-existent variable with a multidimensional array - so no wonder it errors!

How about:

<%if Permissions(0,0) = "SuperUser" then%>



=======================================
LessThanDot - The IT Community of the 21st Century

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top