Link to home
Start Free TrialLog in
Avatar of celler_wellbridge
celler_wellbridgeFlag for United States of America

asked on

Need to add dynamic links to Sharepoint

Privyet good people,

I need to add dynamic links to Sharepoint.

Each link must contain current Windows user name (without machine name) - DONE.

Each link must contain current date (yyyymmdd) - DONE.

Each link must dynamically build in Sharepoint! NOT DONE (tried content and in a template).

I need to get this code working  (ideally) in the top or side nav. Less desirable is to get the dynamic links into an existing page or existing (standard, OEM) web part--inside of Sharepoint (WSS), current version.

And I need to tip-toe through this LIVE SP so it will always update smoothly in the future--so I'm not interested in changing ANY part of SP at the DLL, EXE, COM or some other earth orbiting satellite way :)

Thank you,

Desvidanya

Here is the functional .NET code for the link:
 
<a href="http://www.domainname.com/splogin.php?user=<% Response.Write(Request.ServerVariables["LOGON_USER"].ToString().Split(@"\".ToCharArray())[1]); %>&sec=ABC123<% Response.Write(DateTime.Now.ToString("yyyyMMdd")); %>&target=this%2Fthat.php%3Fthere%3D144%26then%3D1" target="_blank">therethen</a>
 
...and for easier reading:
 
<a href="http://www.domainname.com/splogin.php?user=<% 
Response.Write(Request.ServerVariables["LOGON_USER"]
.ToString().Split(@"\".ToCharArray())[1]); %>&sec=ABC123<% 
Response.Write(DateTime.Now.ToString("yyyyMMdd")); 
%>&target=this%2Fthat.php%3Fthere%3D144%26then%3D1" 
target="_blank">therethen</a>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of raybies
raybies
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of celler_wellbridge

ASKER

Thank you raybies,

I will test this today.

I've had limited success pulling an external aspx page into a page viewer web part (IFrame).

I can get the links to open the new php site logged in and at the correct site area (but only in a new window).

When I try to redirect to the same link structure, in a page viewer web part, SP presents the site--but only at the login page!

I can log in and view the logged in site in the page viewer wep part--and when I open the same SP page in a new instance of the browser, I'm logged in. So I know it can handle displaying the page in the (IFrame) page viewer web part.

I'll try your code the first part of today, and hopefully I'll get it right.

It seems a shame SP will not allow [SIMPLE] devlopment with code behind pages, or at least allow inline code! ...you know, a "control" page or something simple...

FREE BUSINESS IDEA: If somebody is a whiz bang, they might make some cash with a plugin (or web part) for MOSS and WSS that enables a web part which will allow inline code! Seems simple, just wish I had the time--and knew how to spell, and read and write better--I'd do it!

Thank you again,

Christopher
Okay beautiful people,

1. SharePoint has done EVERYTHING in its power to prevent easily integrating an old intranet, from another server, into the new Intranet hanging on SP.

Eff 'em. The only way we get any technology working si to learn what the engineers did to design the system and then test work-arounds.

SP (due to old school frame rules), will not let you display a page in a page viewer web part (an iFrame)--from another server.

I beat my head against this wall trying and trting to get the current Windows user name, hand it off to our old Apach/PHP intranet, get the user logged in to the Intranet (from either side), and then display the old intranet page in SP inside an iFrame so that it looked like part of the NEW intranet, until we can reprogram the functionality in .NET.

It didn't even look good on paper.

So WORK AROUND.

Here's what I did and here's the code.

I abandoned the iFrame--show it in the new Intranet idea. Thank you MS.

I created pages which discovered the current Windows user name.

I dropped that info into a complex string to be handed off to the APache/PHP intranet.

Then I had it all go into a new page which would [old school] meta refresh to the string in a new window.

What a pain in the a--.

But it works (around).

I needed to do this with several pages, leading several people to different areas of the old Intranet.

The solution I present here is two pieces. The code (IMPORTANT! which I placed in the _LAYOUTS directory of the SP server!!!!!!).

The page whish does the user look up and the page which pops a new window with the required old Intranet page displayed.

Here goes.

AND REMEMBER--the pages are placed in the _LAYOUTS directory of SP.

Make a note to double check ALL things when you upgrade SP! And more importantly--get the old intranet functionality re-written in .NET before SP upgrades!!!!

Argue about the method and madness to get this to work. I don't care :) I got it working, pleased some directors, and I'm off to the next 382.79991 projects on my plate :)

Sometimes The Prodigy (at high volume) is useful while coding.... other times you'll find Sting, Social D, or Strauss will open some synaptic ports. If you don't understand this--I know. Unbutton the top button of your Polo brand polo shirt, stop smiling, and we're proud you know everything about COM and the guts of .NET :) As a matter of fact, get your other shirt and your comic book and leave--just leave.

################## 
page tells us Windows user, builds a string and hand it off to the old intranet ##################
 
<%@ Assembly Name="Microsoft.SharePoint.ApplicationPages, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
<%@ Page Language="C#" MasterPageFile="~/_layouts/basicEmpty.master" %>
 
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %>
<%@ Import Namespace="System.Security.Permissions" %>
<%@ Import Namespace="Microsoft.SharePoint.Security" %>
<%@ Import Namespace="System.Diagnostics" %>
 
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
    {
        {            
            string fullURL;
 
            fullURL = "http://www.OldIntranetSite.com/sp_login.php?username=";                                                   // build the base URL
            fullURL += Request.ServerVariables["LOGON_USER"].ToString().Split(@"\".ToCharArray())[1];                            // add the current windows user to the URL 
            fullURL += "&secret=CrazyAssRandomStringHere";                                                                       // add a randomized element to the string (for un hashing on the APACHE/PHP side
            fullURL += DateTime.Now.ToString("yyyyMMdd");                                                                        // add the current date to URL for additional authentication 
            fullURL += "&target=SiteAreaOne%2FSiteAreaType.php%3FLoginType_section%3D73%26IntranetArea_PageType_LoginType=true"; // add the exact place on the old intranet
 
            this.Response.Redirect(this.ResolveUrl(fullURL));                                                                    // redirect them there with the full URL        
         }
    }
    </script>
 
 
##################
Page which pops a new window and re-directs to the old intranet
##################
 
<!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 id="Head1">
    <title>Intranet Area Page Type PageName... redirecting now</title>
    <meta http-equiv="refresh" content="0;url=IntranetArea_PageType.aspx" />
</head>
<body>
    <form name="form1" method="post" action="IntranetArea_PageType.aspx" id="form1">
        <div>
            <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEzNDY4OTc3NDBkZGUdeYUhS2fVce0UjT0/9kvQ/zKr" />
        </div>
        <div>
            <br /><br />
            <br /><br />
            <span style="font-family:Arial,helv,san-serif; 
                color:silver; 
                background-color: white;
                margin-left: 10%; 
                margin-right: 10%; z-index:20;">
                <!-- bottom: 0; -->
                ...redirecting to OurCompanyName, LLC. Intranet Area Page Type PageName
                <br /><br />
                <br /><br />
                <img src="OurCompanyName_Logo.jpg" alt="OurCompanyName, LLC logo image" style="padding-left:170px;" />
            </span>
        </div>
    </form>
</body>
</html>

Open in new window

The solutions proposed by Raybies opened doors to completing the solution.

Thank you Raybies.