Solved

html

Posted on 2011-09-07
5
229 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now