Thursday, July 24, 2014

Disposable type not disposed : Microsoft.SharePoint.SPSite


Hi,

We have found the below error when we were trying to deploy the solution.
Error is clearly saying that SPSite object is not disposable properly.
So we have disposed SPSite object by using statement as below. Then it got deployed successfully.


Saturday, May 10, 2014

People Picker Issue on all Browsers

Hi ,
Generally we would be facing an issue with people picker on IE9/IE8 browsers.
It will not be visible to the user, for below is the remedy that we got from our teammate.

Below is the js code. We had directly added it in master page and it should be placed at the end of master page or put it in a separate js file and provide the reference at the end:

<!--People picker fix starts-->
<script type="text/javascript">
function ConvertEntityToSpan(ctxentity)
{ULSGjk:;
    if(matches[ctx]==null)
        matches[ctx]=new Array();
    var key=entity.getAttribute("Key");
    var displayText=entity.getAttribute("DisplayText");
    var isResolved=entity.getAttribute("IsResolved");
    var description=entity.getAttribute("Description");
    var style='ms-entity-unresolved';
    if(isResolved=='True')
        style='ms-entity-resolved';
    var spandata="<span id='span"+STSHtmlEncode(key)+"' isContentType='true' tabindex='-1' class='"+style+"' ";
    if (browseris.ie8standard)
        spandata+="onmouseover='this.contentEditable=false;' onmouseout='this.contentEditable=true;' contentEditable='true' ";
    else
        spandata+="contentEditable='false' ";
    spandata+="title='"+STSHtmlEncode(description)+"'>"
    spandata+="<div style='display:none;' id='divEntityData' ";
    spandata+="key='"+STSHtmlEncode(key)+"' displaytext='"+STSHtmlEncode(displayText)+"' isresolved='"+STSHtmlEncode(isResolved)+"' ";
    spandata+="description='"+STSHtmlEncode(description)+"'>";
    var multipleMatches=EntityEditor_SelectSingleNode(entity"MultipleMatches");
    matches[ctx][key]=multipleMatches;
    var extraData=EntityEditor_SelectSingleNode(entity"ExtraData");
    if(extraData)
    {
        var data;
        if(extraData.firstChild)
            data=extraData.firstChild.xml;
        if(!data) data=extraData.innerXml || extraData.innerHTML;
        if(!data && document.implementation && document.implementation.createDocument)
        {
            var serializer=new XMLSerializer();
            data=serializer.serializeToString(extraData.firstChild);

                    // **** CUSTOM FUNCTION ****
            data fixDataInIE9(data);
        }
        if(!data) data='';
        spandata+="<div data='"+STSHtmlEncode(data)+"'></div>";
    }
    else
    {
        spandata+="<div data=''></div>";
    }
    spandata+="</div>";
    if(PreferContentEditableDiv(ctx))
    {
        if(browseris.safari)
        {
            spandata+="<span id='content' tabindex='-1' contenteditable='false'  onmousedown='onMouseDownRw(event);' onContextMenu='onContextMenuSpnRw(event,ctx);' >";
        }
        else
        {
            spandata+="<span id='content' tabindex='-1' contenteditable onmousedown='onMouseDownRw(event);' onContextMenu='onContextMenuSpnRw(event,ctx);' >";
        }
    }
    else
    {
        spandata+="<span id='content' tabindex='-1' contenteditable onmousedown='onMouseDownRw(event);' onContextMenu='onContextMenuSpnRw(event,ctx);' >";
    }
    if (browseris.ie8standard)
        spandata+="\r";
    if(displayText !='')
        spandata+=STSHtmlEncode(displayText);
    else
        spandata+=STSHtmlEncode(key);
    if (browseris.ie8standard)
        spandata+="\r</span></span>\r";
    else
        spandata+="</span></span>";
    return spandata;
}

// **** CUSTOM FUNCTION ****
function fixDataInIE9(data)
{

    if(data.indexOf('<ArrayOfDictionaryEntry>'>= 0)
    {
        data data.replace('<ArrayOfDictionaryEntry>''<ArrayOfDictionaryEntry xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema-instance\">');
    }
    return data;
}
</script>


And add this css in master page.

/*People picker fix*/
<style type=”text/css”>
div.ms-inputuserfield > span.ms-entity-resolved{display:inline-block}​
</style>

Sunday, March 23, 2014

Modal Popup using javascript post File Upload

Hi,

We have a file upload web part where
User needs to upload the file in .xls or .xlsx format only.
Once user uploads the file, confirmation dialog box needs to displayed or alert message needs to be displayed to upload in the specified format.
For this we have created div tag with label control and ok button that needs to be displayed as the confirmation.
Below is the div tag created to display the pop in the center of the page.
Below is the java script function in which we are
Calling the div id to display the pop up on the center of the page.
Calling the div to display the confirmation pop up.
Assigning the label to the parameter of the function as below

Finally in the upload button click we are assigning the value so that this message is returned to the function through parameter.
We are assigning the message to the client ID of the label to display the same.
Finally we are able to get the modal pop up as below post uploading the file.


Wednesday, June 26, 2013

Database Movement from One Web Application to another using Powershell

We may have necessity of moving databases of one web application the other.
If the databases are in bulk, then we move ahead by automating with power shell as below
Below is the script that has been written to move database from one web application the other
// DBMove.bat
cd /d %~dp0
@echo off
powershell.exe -noexit .\DBMove.ps1 .\DBMove.csv
// DBMove.csv
SourceWebAppUrl,DestinationWebAppurl
// DBMove.ps1
#-----Input parameters to the script
param($inputFile)

#------To check if Sharepoint cmdlets are registered are registered
if ((Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
{
            Add-PSSnapin Microsoft.SharePoint.Powershell 
}
#---------------------------------------------------------------------------------------------------
#-----------------------------------------Start Logging---------------------------------------------
$filepath = $MyInvocation.MyCommand.Definition                                        
$directorypath = [System.IO.Path]::GetDirectoryName($filepath)
$LogTime = Get-Date -Format yyyy-MM-dd_h-mm
$LogFile = $directorypath + "\DBMove_Log_$LogTime.txt"
Start-Transcript -Path $LogFile -Force
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function DBMove()
{
param([string] $swebAppUrl,[string] $dwebAppUrl)

$SourceWebApp = Get-SPWebApplication -Identity $sourcewebAppUrl
$DestinationWebApp = Get-SPWebApplication -Identity $destinationwebAppUrl

if($SourceWebApp -ne $null -and  $DestinationWebApp -ne $null)
{

$SourceDBlists=Get-SPContentDatabase -WebApplication $SourceWebApp
Get-SPContentDatabase -WebApplication $SourceWebApp  | Dismount-SPContentDatabase -confirm:$false
foreach ($SourceDBlist in $SourceDBlists)
{
 Mount-SPContentDatabase $SourceDBlist.Name -DatabaseServer $SourceDBlist.Server -WebApplication $destinationwebAppUrl
}
}
else
{
  Write-Host 'Not a valid Web application url...'
}

}

#---------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------
#loop through a csv file
Import-Csv $inputFile | ForEach{                            
    $SourcewebAppUrl = $_. SourceWebAppUrl
    $destinationAppUrl = $_.DestinationWebAppurl
              
    try
    {
  write-host "Moving Source Database from $sourcewebAppUrl to $destinationwebAppUrl...."
        SourceDBMove $sourcewebAppUrl,$destinationwebAppUrl
  write-host "Completed..."
    }
    catch
    {
  write-host "Completed with errors..."   
        Write-Output $_
    }
}
#---------------------------------------------------------------------------------------------------

#-----------------------------------------End Logging-----------------------------------------------
Stop-Transcript
#---------------------------------------------------------------------------------------------------


Portal Site Connection Url Updation using Powershell

Hi,
Generally in our site collection, we could have updated portal site name, portal site url to get the site hierarchy. We follow the below navigation to update the portal site name,url. But if there are twenty site collections where we need to update portal site name,url. At that time PowerShell script can ease the task for the same as below
//PortalSiteConnection.bat
cd /d %~dp0
@echo off
powershell.exe -noexit .\PortalSiteConnection.ps1 .\PortalSiteConnection.csv
//PortalSiteConnection.csv
MainWebAppurl
//PortalSiteConnection.ps1
#-----Input parameters to the script
param($inputFile)

#------To check if Sharepoint cmdlets are registered are registered
if ((Get-PSSnapin -Name Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue) -eq $null )
{
            Add-PSSnapin Microsoft.SharePoint.Powershell 
}
#---------------------------------------------------------------------------------------------------
#-----------------------------------------Start Logging---------------------------------------------
$filepath = $MyInvocation.MyCommand.Definition                                       
$directorypath = [System.IO.Path]::GetDirectoryName($filepath)
$LogTime = Get-Date -Format yyyy-MM-dd_h-mm
$LogFile = $directorypath + "\PortalSiteConnectionSettings_Log_$LogTime.txt"
Start-Transcript -Path $LogFile -Force
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function PortalSiteConnectionSettings()
{
param([string] $mwebAppUrl)

$MainWebApp = Get-SPWebApplication -Identity $mainwebAppUrl

if($MainWebApp -ne $null)
{


get-spsite $($MainWebApp.Url + "*" ) -Limit ALL | ForEach-Object{if($_.PortalUrl.Contains(“https://abc”) –and ($_.PortalUrl -ne $null)){

$_.PortalUrl = $_.PortalUrl.Replace("https:// abc.", " https://xyz");

}

}
}
}


#---------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------
#loop through a csv file
Import-Csv $inputFile | ForEach{                                
    $mainwebAppUrl = $_.MainWebAppurl  
    try
    {
  write-host "Updating Provisioning Url in portal site connection...."
        PortalSiteConnectionSettings $mainwebAppUrl
  write-host "Portal Site Connection Url has been updated" -ForegroundColor Green
    }
    catch
    {
  write-host "Completed with errors..."   
        Write-Output $_
    }
}
#---------------------------------------------------------------------------------------------------

#-----------------------------------------End Logging-----------------------------------------------
Stop-Transcript
#---------------------------------------------------------------------------------------------------

Note:
Before running this script,make sure that the account with which this script is executing is holding Farm admin privilege (or)
Before running this script,make sure that the account with which this script is  executing is member of admin group under every site collection of mentioned Web Application  

Wednesday, June 19, 2013

User Profile Import in SharePoint 2010

Hi,

I am posting the article of User Profile Import in SharePoint 2010 as below

2.1.1      Check the User Profile Service status

·         On the Central Administration Web site, in the System Settings section, click Manage services on server.
·         On the Services on Server page, in the Server box, select the synchronization server.
·         Find the row whose Service column value is User Profile Synchronization Service.
·         Check whether the value in the Status column is started.
If the value in the Status Column for the User profile synchronization service is started “Forefront Identity Manager Service” and“Forefront Identity Manager Synchronization Service” (which is available in Start | Run | services.msc) should be started automatically.                  

2.1.2      Create a synchronization connection to a directory service


To import profiles, you must have at least one synchronization connection to a directory service, create a synchronization connection to each directory service that you want to import profiles from. You can synchronize after you create each connection, or you can synchronize one time, after you have created all of the connections. Synchronizing after each connection will take longer, but doing this will make it easier to troubleshoot any problems that you might encounter.
The connection identifies the items to synchronize and contains the credentials that are used to interact with the directory service.
·         On the Central Administration Web site, in the Application Management section, click Manage service applications.
   
·         On the Manage Service Applications page, click on AZ ESP User Profile Service Application.
·         On the Manage Profile Service page, in the Synchronization section, click Configure Synchronization Connections.
  
abc & xyz Domain users will be imported to SharePoint User Profile Store and the following connection will be created,
1.     All abc Domain Users
2.     All xyz Domain Users

2.1.2.1  All AZ Domain Users

·         On the Synchronizations Connections page, click Create New Connection.
   
·         On the Add new synchronization connection page, type the synchronization connection name in the Connection Name asAll abc Domain Users.
·         In the Forest name box, type the name of the forest as abc.net.
·         Select “Auto domain discover controller” in the Connection Settings.
·         In the Authentication Provider Type box, select the type of authentication as Windows Authentication.
·         In the Account name box, type the synchronization account
·         In the Password box, type the password for the synchronization account.
·         In the Confirm Password box, type the password for the synchronization account again.
·         In the Port box, enter the connection port as 389.
·         Unselect Use SSL-secured connection.
·         In the Containers section, click Populate Containers, and then select the containers as shown in the below figure
·         Click OK.

2.1.2.1.1      Define exclusion filters for a synchronization connection


·         On the Central Administration Web site, in the Application Management section, click Manage service applications.
·         On the Manage Service Applications page, click the User Profile Service Application Name.
·         On the Manage Profile Service page, in the Synchronization section, select Configure Synchronization Connections.
·         On the Synchronization Connections page, Select the connection All abc Domain Users and then click Edit Connection Filters.
·         On the Edit connection filters page, in the Exclusion Filters for Users section, perform the following steps:
                      i.        Select userAccountControl from Attribute drop-down, select Bit on equals from Operator drop-down, enter 2 in Filter text box and then click on Add.
                              ii.            Select Any apply (OR) option in Exclusion Filters for Users.
                            iii.            Select division from Attribute drop-down, select Equals from Operator drop-down, enter 0 in Filter text box and then click on Add.
                            iv.            Select Any apply (OR) option in Exclusion Filters for Users.
                              v.            Select division from Attribute drop-down, select Equals from Operator drop-down, enter 15 in Filter text box and then click on Add.
                    vi.        Select Any apply (OR) option in Exclusion Filters for Users.
                   vii.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 17 in Filter text box and then click onAdd.
                  viii.        Select Any apply (OR) option in Exclusion Filters for Users.
                    ix.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 18 in Filter text box and then click onAdd.
                     x.        Select Any apply (OR) option in Exclusion Filters for Users.
                    xi.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 19 in Filter text box and then click onAdd.
                   xii.        Select Any apply (OR) option in Exclusion Filters for Users.
                  xiii.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 33 in Filter text box and then click onAdd.
                 xiv.        Select Any apply (OR) option in Exclusion Filters for Users.
                  xv.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 34 in Filter text box and then click onAdd.
                 xvi.        Select Any apply (OR) option in Exclusion Filters for Users.
                xvii.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 41 in Filter text box and then click onAdd.
               xviii.        Select Any apply (OR) option in Exclusion Filters for Users.
                 xix.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 49 in Filter text box and then click onAdd.
                  xx.        Select Any apply (OR) option in Exclusion Filters for Users.
                 xxi.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 62 in Filter text box and then click onAdd.
                xxii.        Select Any apply (OR) option in Exclusion Filters for Users.
               xxiii.        Select division from Attribute drop-down, select Equals from Operator drop-down, enter 63 in Filter text box and then click onAdd.
               xxiv.        Select Any apply (OR) option in Exclusion Filters for Users.
                xxv.        Select division from Attribute drop-down, select Is not present from Operator drop-down, then click on Add.


               xxvi.        Click on Ok.

2.1.2.2  All xyz Domain Users

·         On the Synchronizations Connections page, click Create New Connection.
   
·         On the Add new synchronization connection page, type the synchronization connection name in the Connection Name asAll abc Domain Users.
·         In the Forest name box, type the name of the forest as abc.com
·         Select “Auto domain discover controller” in the Connection Settings.
·         In the Authentication Provider Type box, select the type of authentication as Windows Authentication.
·         In the Account name box, type the synchronization account.
·         In the Password box, type the password for the synchronization account.
·         In the Confirm Password box, type the password for the synchronization account again.
·         In the Port box, enter the connection port as 389.
·         Unselect Use SSL-secured connection.
·         In the Containers section, click Populate Containers, and then select only the below containers as shown in the below table (abc->Accounts->Regions)
1
OU=OUName,OU=OUContainerName,OU=EU,OU=Regions,OU=Accounts,DC=xyz,DC=com
2
OU= OUName,OU= OUContainerName,OU=EU,OU=Regions,OU=Accounts,DC= xyz,DC=com
3
OU= OUName,OU= OUContainerName,OU=EU,OU=Regions,OU=Accounts,DC= xyz,DC=com
4
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
5
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
6
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
7
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
8
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
9
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
10
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
11
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
12
OU= OUName,OU= OUContainerName,OU=US,OU=Regions,OU=Accounts,DC= xyz,DC=com
·         Click OK.

2.1.2.2.1      Define exclusion filters for a synchronization connection

·         On the Central Administration Web site, in the Application Management section, click Manage service applications.
·         On the Manage Service Applications page, click the User Profile Service Application Name.
·         On the Manage Profile Service page, in the Synchronization section, select Configure Synchronization Connections.
·         On the Synchronization Connections page, Select the connection All xyz Domain Users and then click Edit Connection Filters.
·         On the Edit connection filters page, in the Exclusion Filters for Users section, perform the following steps:
              xxvii.        Select userAccountControl from Attribute drop-down, select Bit on equals from Operator drop-down, enter 2 in Filter text box and then click on Add.
                xxviii.            Click on Ok.

2.1.3      Schedule User Profile Incremental Synchronization


·         On the Central Administration Web site, in the Application Management section, click Manage service applications.
·         On the Manage Service Applications page, click in the Title column of the User Profile Service Application Name row to select it.
·         In the Operations group of the ribbon, click Manage.
·         On the Manage Profile Service page, in the Synchronization section, click Configure Synchronization Timer Job.
·         On the Edit Timer Job page, in the Recurring Schedule section, select the schedule as 1:00 AM to 2.00 AM, when you want recurring Profile Synchronization to occur and then click OK.

2.1.4      Configure Synchronization Settings

·         On the Central Administration Web site, in the Application Management section, click Manage service applications.
·         On the Manage Service Applications page, click in the Title column of the User Profile Service Application Name row to select it.
·         In the Operations group of the ribbon, click Manage.
·         On the Manage Profile Service page, in the Synchronization section, click Configure Synchronization Settings
·         On the edit Configure Synchronization Settings page, in Synchronization Entities section select Users Only option and then click OK