• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Dynamic Hyperlinks or Conditional Hyperlinks

I am trying setup a page that has a "conditional" link or dynamic link.
I may not be using the proper name for it so i will tell you what i am trying to do.

The page i have has the Active Directory connector on it. and what i want to happen is this.

If a user from the the executive member group logs on i want the continue link to goto the "executive" page.
and if a normal user logs on then i want it to goto their page.

Attached is my asp code.

i dont know if i can use an "IF" statement or not.

<%@ LANGUAGE=VBSCRIPT %>
<%Option Explicit%>
 
<%
 ' Check to see if the session variable is already populated.
  If Session("LOGON_USER") = "" Then
    ' Check to see if the user has logged on at all.
    If Request.ServerVariables("LOGON_USER") = "" Then
      ' Force authentication if not.
      Response.Clear
      Response.Status = "401 Access Denied"
      Response.End
    Else
      ' Store the client's user name in a session variable.
      Session("LOGON_USER") = Request.ServerVariables("LOGON_USER")
      ' Strip out an NT domain from the user name.
      If InStr(Session("LOGON_USER"),"\") then
                    Session("LOGON_USER") = Mid(Session("LOGON_USER"), InStr(Session("LOGON_USER"), "\") + 1)
 
      End If
    End If
  End If
Function getADUserInfo(strUID)
	on error resume next
	strGeneralLookupError = false
    strBase = "<LDAP://DC=diamed, DC=local>"
	strFilter = "(sAMAccountName=" & strUID & ")" 
	strAttributes = "cn, mail, company, givenName, sn, ADsPath, name, sAMAccountName, telephoneNumber, physicalDeliveryOfficeName"
	strScope = "subtree"	
	strFullCommand = strBase & ";" & strFilter & ";" & strAttributes & ";" & strScope
	set rsADUserInfo = Server.CreateObject("ADODB.Recordset")
	set	rsADUserInfo = connAD.Execute(strFullCommand)
	if err.number <> 0 then
		strGeneralLookupError = true
	end if
	set getADUserInfo = rsADUserInfo
	set rsADUserInfo = Nothing
End Function
 
Sub getUserData(p_strUserID)
	on error resume next
	set rsUserData = Server.CreateObject("ADODB.Recordset")
	set rsUserData = getADUserInfo(p_strUserID)
	if not rsUserData.EOF then
		strUserGN = rsUserData("givenName")
		strUserSN = rsUserData("sn")
		strUserOU = rsUserData("company")
		strUserOF = rsUserData("physicalDeliveryOfficeName")
		strUserEmail = rsUserData("mail")
		strUserPhone = rsUserData("telephoneNumber")
	else
		strADLookupSuccess = false
	end if
	rsUserData.Close
	set rsUserData = Nothing
End Sub
 
on error resume next
 
response.expires = 0
 
DIM connAD, rsUserData, rsADUserInfo
DIM strUserGN, strUserSN, strUserOU, strUserEmail, strUserOF,strUserPhone
DIM strBase, strFilter,strAttributes, strScope, strFullCommand
DIM strGeneralLookupError, strADLookupSuccess
DIM strUserID
 
strUserGN = "The user can not be found in the system."
strGeneralLookupError = false
strADLookupSuccess = true
 
set connAD = Server.CreateObject("ADODB.Connection")
connAD.Provider = "ADsDSOObject"
connAD.Properties("User ID") = "diamed0\administrator" ' ### remember to make sure this user has rights to access AD
connAD.Properties("Password") = "*********"
connAD.Properties("Encrypt Password") = true
connAD.Open
 
strUserID = Session("LOGON_USER")
call getUserData(strUserID)
 
connAD.Close
set connAD = Nothing
%>
 
<style type="text/css">
<!--
.style1 {
	font-size: 36px;
	font-weight: bold;
}
.style2 {font-size: 24px}
-->
</style>
<div align="center">
  <h1><script type="text/javascript">
var d = new Date();
var time = d.getHours();
 
if (time < 11) 
{
document.write("<b>Good morning</b>");
}
if (time > 5) 
{
document.write("<b>Good Evening</b>");
}
else
{
document.write("<b>Good Afternoon</b>");
}
</script>
    <br />
    <br />
  Welcome To REPCOM</h1>
  <h1><%=strUserGN%></span></b>&nbsp;<span 
                    class="style6"><%=strUserSN%><br /></h1>
  Your Assigned Rep Number is <%=strUserOF%>
</div>
<p align="center" class="style1">&nbsp;</p>
<table width="253" border="1" align="center" bordercolor="#0000FF">
  <tr>
    <td width="243"><div align="center"><span class="style1"><a href="/repcom/Users/<%=UCase(Session("LOGON_USER"))%>/index.asp" class="style2">Click Here To Login</a></span></div></td>
  </tr>
</table>
<p align="center" class="style1">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><a href="Users/general/Index.asp">General Access</a></p>
<p align="center"><a href="/Repcom/Template/Index.asp"><strong>Executive Access</strong></a><br />
</p>

Open in new window

0
phoenixfire425
Asked:
phoenixfire425
  • 2
1 Solution
 
Tony McCreathTechnical SEO ConsultantCommented:
How do you determine the user is an executive, I don't se any code for that?

Once you have determined that you should be able to do an IF

I also don't see a continue link? Are you talking about the two links at the bottom?
<% If Session("EXECUTIVE") Then %>
<p align="center"><a href="/Repcom/Template/Index.asp"><strong>Executive Access</strong></a>
<% Else %>
<p align="center"><a href="Users/general/Index.asp">General Access</a></p>
<% End If %>

Open in new window

0
 
phoenixfire425Author Commented:
Well I am trying now to pull in the "member of" for the user now.  So its not in there yet.

I cant seem to figure out a way to have it find out if the user is a part of the Executive group or the Non-Executive group.  Any ideas?
0
 
Tony McCreathTechnical SEO ConsultantCommented:
This is more of an asp and Active Directory problem.

You may get more help if to re-assign it to those zones.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now