Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

html

Posted on 2011-09-07
5
Medium Priority
?
241 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

886 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