Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

html

Posted on 2011-09-07
5
234 Views
Last Modified: 2012-05-12
I have never worked in .net or html environment. I am trying to add a button on a html page that runs a vbscript. Also, I need to add a link on html that would only allow certain people have access to the link. Is there anyway that link would only let the domain admins to open it?

Thanks,
Paul
0
Comment
Question by:pauledwardian
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:jagrut_patel
ID: 36500979
For Button that runs VBScript look this link. It also shows example so should be easy for you to copy that in your web-page.
http://www.csidata.com/custserv/onlinehelp/vbsdocs/vbs9.htm

For admin specific link you will need to write some ASP.NET code.

In your ASPX web-page put the following,

<asp:LinkButton ID="AdminLink" Text="Only for Admin" runat="server" Visible="false"></asp:LinkButton>

In your code-behind (aspx.cs) of that page write

protected void Page_Load(object sender, EventArgs e)
{
    bool isAdminUser = false;
    //Put code that determines whether current user is Admin. If user is Admin set isAdminUser = true;            
    AdminLink.Visible = isAdminUser;
}

Open in new window


HTH!

0
 
LVL 9

Expert Comment

by:djpazza
ID: 36529096
Is it asp.net your are after or vb script asp?
0
 

Author Comment

by:pauledwardian
ID: 36533116
Bacially, I need it to run a vbscript. But only lets the domain admins to run it from the html.
0
 
LVL 9

Accepted Solution

by:
djpazza earned 500 total points
ID: 36535224
I'm not sure what your after here.  Firstly you can not run vb script from just html you need a server side scripting language like asp,aspx.

If it a vb file (.vbs) that you need to run just as admins then put the scripts in a folder and only give admins access to the folder.

If you have vb script inside an asp page then you could restrict access to the page(s) using your webserver e.g iis.  On the security options use windows authenction and give admins permission to the web folder.  This way they will authenticate automatically using their windows credentials but other users with get a login prompt.

The other option is to still user windows authentication as this gives you access to some variables to query ad via a script using ldap.

The attached code will only display domain admin information if the current user is in the domain admin group.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
'Get Groups
Dim objNetwork, objUser, CurrentUser
Dim strGroup

	Const backup_Group = "cn=domain admins"

	Set objNetwork = CreateObject("WScript.Network")
	Set objUser = CreateObject("ADSystemInfo")
	Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
	strGroup = LCase(Join(CurrentUser.MemberOf))
	'response.Write strGroup

  If InStr(strGroup,backup_Group) Then
    session("auth") = "True"
  End If
  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Restrict Access</title>
</head>

<body>
<div style="margin-bottom:30px;">All Users can see this content</div>
<% if session("auth") = "True" then %>
<div style="margin-bottom:30px;">Only admins can see this content</div>
<% end if %>
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:pauledwardian
ID: 36547115
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question