Create dynamic links based on user profile data

I have a SP 2010 site where the main site is one web application, then customer sites are separate web applications. I had to do this to maintain separate AD authentication, etc. for the customer sites. On the main site, I want to setup a link to their web application/site collection based upon their user domain information. Essentially, all of the customer domains are named customer1.localdomain, customer2.localdomain and so forth. Their SP sites are named SharePoint.Customer1.LocalDomain, SharePoint.Customer2.Localdomain and so on. All customers are allowed to log into the main site with their particular customer AD credentials.

What I am trying to do is dynamically build a link to their SP site from the main site using the logged on user's domain name. What I think I could potentially do, is create a calculated value "http://SharePoint" + LoggedInCustomerDomainName + "LocalDomain" as the hyperlink's value. I am just not sure how to do this, then add it either to the quick launch, or even to the page they are presented with assuming there is some type of personal (per user) section/widget on the page if there is even such a thing.

Any help here would be great. I am not a programmer, so I cannot go do far in depth in coding this

September 6th, 2013 3:24am

Hi,

From your description, you want to create a hyper-link for domain users (customers) in the main site which points to customer's site.

Lets check the possible workarounds that you can choose according to your requirement.

1. Add Content Editor web part which to mail site which represent customers site. This JavaScript will get the alias (SAM account name) of the current logged-on user and dynamically output the URL with user account name included.

<script type="text/javascript">
    ExecuteOrDelayUntilScriptLoaded(getWebUserData, "sp.js");
    var context = null;
    var web = null;
    var currentUser = null;
    function getWebUserData() {
        context = new SP.ClientContext.get_current();
        web = context.get_web();
        currentUser = web.get_currentUser();
        currentUser.retrieve();
        context.load(web);
        context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), 
             Function.createDelegate(this, this.onFailureMethod));
    }
    function onSuccessMethod(sender, args) {
        var userObject = web.get_currentUser();
var loginname=userObject.get_loginName();
var LoginAlias=loginname.substring(loginname.lastIndexOf('\\')+1,loginname.length);
var link='http://SharePoint.' + LoginAlias +'.localdomain';
document.getElementById("Ulink").innerHTML = link ;
    alert(link );
    }
</script>
<div>User's site:<label id="Ulink"></label></div>

2.  Get username via SharePoint Designer in DataFormWebPart.

http://blogs.msdn.com/b/joshuag/archive/2008/06/03/getting-the-current-user-name-or-id-in-sharepoint-using-sharepoint-designer-no-code.aspx

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2013 3:25am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics