Monday, December 22, 2014

In Content editor webpart , Image Rotation at the time of page refreshing


<div id="mainarea"><!-- Start Featured Items -->
<div class="cta cta_featured f0">

target="_blank"><img src="/EN/Documents/images/GlobalInnovators_2.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f1" style="display: none;">
                <a href="http://www.latimes.com/business/realestate/la-fi-robinsons-asian-

investors-20140912-story.html" target="_blank"><img src="/EN/Documents/images/Asian-

Capital.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f2" style="display: none;">
                <a href="/EN/aboutus/MediaCentre/2014/Pages/Euromoney-2014.aspx"><img

src="/EN/Documents/images/Euromoney-Awards-2014.jpg" alt=""/></a>
</div>
<div class="cta cta_featured f3" style="display: none;">
                <a href="/EN/aboutus/corporateresponsibility/Pages/default.aspx"><img

src="/EN/Documents/images/2013-corporate-responsibility.jpg" alt=""/></a>
</div>

<div class="cta cta_featured f4" style="display: none;">
                <a href="http://annualreport.cbre.com/"><img src="/EN/Documents/images/Annual-

Report.jpg" alt=""/></a>
</div>
<!-- End Featured Items -->

<script>
(function() {

                // Begin Featured randomizing/cycling section
                function createCookie(name, value, days) {
                                if (days) {
                                                var date = new Date();
                                                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                                                var expires = "; expires=" + date.toGMTString();
                                }
                                else var expires = "";
                                document.cookie = name + "=" + value+expires + "; path=/";
                }

                function readCookie(name) {
                                var nameEQ = name + "=",
                                                ca = document.cookie.split(';');
                                for(var i = 0; i < ca.length; i += 1) {
                                                var c = ca[i];
                                                while (c.charAt(0)==' ') {
                                                                c = c.substring(1,c.length);
                                                }
                                                if (c.indexOf(nameEQ) == 0) {
                                                                return c.substring(nameEQ.length,c.length);
                                                }
                                }
                                return null;
                }

                function eraseCookie(name) {
                                createCookie(name,"",-1);
                }
               
                function itemCyclerRandomizer($collection, cookieName) {
                                var len = $collection.length,
                                                rand = Math.floor(Math.random() * len),
                                                lastItem = parseInt(readCookie(cookieName));

                                if (lastItem !== lastItem) { // true if NaN, which means no cookie
                                                lastItem = rand;
                                } else {
                                                if (lastItem >= len - 1) {
                                                                lastItem = 0;
                                                } else {
                                                                lastItem += 1;
                                                }
                                }

                                createCookie(cookieName, lastItem);

                                $($collection.get(lastItem)).show();
                               
                }
               
                itemCyclerRandomizer($('.cta_featured'), 'lastFeatured');
                itemCyclerRandomizer($('.cta_news .item'), 'lastNews');
                itemCyclerRandomizer($('.cta_case-study .item'), 'lastCaseStudy');
                // End Featured randomizing/cycling section
               
                // Click functionality for world office location dropdown
                $("#mapCtaLink").click(function() {
                                openWorldMenu();
                                $('html, body').animate({
                                                scrollTop: $("#world_office_menu").offset().top
                                }, 1000);
                });
               
                // Add class to fix IE8 nth-child support
                $('.cta_x2:nth-child(2n+2), .cta_x3:nth-child(3n+3)').addClass('row-end');
}());

$( document ).ready(function() {
    // alert("hi");
    $(".cta cta_featured f0").show();
});

</script>

Wednesday, November 5, 2014

EDIT global.ascx

<script runat="server">


    void Application_BeginRequest(object sender, EventArgs e)
    {

        if (HttpContext.Current.Request.RawUrl.Contains("/_layouts/mngsiteadmin.aspx"))
        {
            //Response.Redirect("/_layouts/copy_mngsiteadmin.aspx");
            Response.Redirect(HttpContext.Current.Request.RawUrl.Remove(HttpContext.Current.Request.RawUrl.LastIndexOf("/")) + "/custom/HTMLPage1.htm");
        }
    }
  </script>

Steps - HTTPModule to redirect mngsiteadmin.aspx page


  1. Open vsual studio
  2. Create a class library project
  3. add system.web reference
  4. inherit IHttpModule
  5. Put the code below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace ModuleHttp
{
    public class ModuleRedirect1 : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.BeginRequest += new EventHandler(context_BeginRequest);
        }
        void context_BeginRequest(object sender, EventArgs e)
        {
            // throw new Exception("The method or operation is not implemented.");
            HttpApplication oApp = (HttpApplication)sender;
            if (oApp.Request.RawUrl.Contains("/_layouts/mngsiteadmin.aspx"))
            {
                oApp.Response.Redirect(oApp.Request.RawUrl.Remove(oApp.Request.RawUrl.LastIndexOf("/")) + "/copy_mngsiteadmin.aspx");
            }
        }
        public void Dispose()
        {
        }
    }
}

6. deploy the code
7. put the code in assembly / GAC

8. add reference to web.config under <modules runAllManagedModulesForAllRequests="true">

<add name='MyHttpModule' type='ModuleHttp.ModuleRedirect1,ModuleHttp,Version=1.0.0.0,Culture=neutral, PublicKeyToken=f2b9e495ae2296c1' />

<add name='ANY NAME' type='NAMESPACE.CLASSNAME,NAMESPACE,Version=1.0.0.0,Culture=neutral, PublicKeyToken=f2b9e495ae2296c1' />

9. MOST IMPORTANT - DO IISRESET . changes may not reflect else.

Monday, November 3, 2014

The specified user domain\username could not be found. Some or all identity references could not be translated.

Scenario: You are trying to create a managed account.



​It can be frustrating when you are sure an account exists in Active Directory and you can't create a managed account for some reason. 

There are two likely reasons: 

1.you miss-typed the username, or you forgot to prefix the username with the domain. That probably accounts for 90% of cases, but there are a couple of others, so if you have already checked the spelling, read on:

2.For some reason, the username that is picked up when creating the managed account is the "User log on name (pre-Windows 2000)" that you see when you create the user or in the Accounts tab on the Properties page for the user in Active Directory Users and Computers. Normally this would be the same as the User Log on Name and the Display Name. However you can set these independently, so that is the first thing to watch for, particularly if you changed the user name at some point after it was created.

3.Another gotcha is that if you enter a username that is longer than 20 characters, you will notice that the legacy pre-Windows 2000 username is truncated to the first 20 characters. Again, that truncated name is the one that is used when you create a managed account. Probably the best plan is to just avoid using names longer than 20 characters, otherwise it gets too confusing.


In my case :- 

Username: tnd_svc_sptfarm-ldev --> Working (20 char)

Username: tnd_svc_sptapool-ldev --> Not Working (21 char)

Username: tnd_svc_sptsvcs-ldev  --> Working (20 char)