Tuesday, July 24, 2012

Few Checklist Items in SharePoint Environment

[  ] Input surfaces in Web parts and other customizations include boundary checks, input data integrity checks, and appropriate exception handling to protect from cross-site scripting and SQL injection.

[  ] You avoid using AllowUnsafeUpdates. You use ValidateFormDigest() and, if necessary, use elevated privileges to interact with SharePoint objects. In cases where AllowUnsafeUpdates must be used, you ensure that AllowUnsafeUpdates is set to False in your try-catch-finally block, or you use a Dispose() method (as required by the IDisposable interface) to avoid security issues.

[  ] Sensitive data is not cached. Output caching is off by default.

[  ] Sensitive data that is transferred via e-mail uses S/MIME encryption or Information Rights Management (IRM), depending upon the intended recipient.

[  ] The application uses a standardized approach to structured error and exception handling throughout.
[  ] Error-handling code inherits from the SPException class to maintain a consistent SharePoint look and feel for errors.
[  ] The application returns generic custom error messages to the client.

[  ] The code uses exception handling. The code catches only the exceptions that you know about. For example, do not use try{} catch(Exception ex){} unless you throw the error again.

[  ] Custom Web parts (including resource files) are contained within a SharePoint Feature and are packaged as a SharePoint solution in order to be deployed.
[  ] The configuration of Web parts that are being deployed gives the administrator the flexibility of deploying to the Web application level or lower.
[  ] You use the SharePoint Web part infrastructure's standardized set of connection interfaces for Web parts to exchange information with each other at run time.
[  ] Source code for third party Web parts solutions, whenever possible, is provided with adequate documentation to ensure good technical support.
[  ] All custom Web parts utilize the SharePoint architecture to ensure consistent behavior across the application for functionality such as single sign-on, feature deployment, and so on.
[  ] Customizations are accompanied by installation instructions that detail how to install and uninstall the package. Architecture diagrams that are related to the installation of the solution are included. If it is not possible to roll back a solution, this must be explained in the installation instructions so that you can discuss the risks and prepare a plan for a system recovery.
[  ] Your application does not try to directly access any SharePoint databases. Data stores in SharePoint databases are only updated by using the SharePoint object model.
[  ] You avoid hard coding strings and labels. You use resources or language files instead.
[  ] When referencing the SPWeb or SPSite objects, you employ a using statement or, alternatively, you use an explicit call of the .Dispose method to ensure proper use and disposing of the memory objects.
[  ] You use caching as appropriate to reduce unnecessary round trips. For Web parts, you expose the cache expiration (duration) as a Web part property.
[  ] When packaging your solution, you include a Code Access Security policy for the solution and, if necessary, include your assembly in the Safe Controls list though the solution.
[  ] When logging code, you use the Portal Log class to log the SharePoint Unified Logging Service (ULS) logs.
[  ] If you need to update multiple list items by using remote code, you use the Web service to update list items. You only use SPListItem.Update() if you have to update more than one item at a time by using local OM-based code.
[  ] When using the Count property of a SPListItemCollection, you only call it once and then store it in a variable that you can refer to when looping. You do not call it inside a loop.

Monday, July 23, 2012

A Few Important Keywords for SharePoint Starters!

Assembly: A collection of one or more files that is versioned and deployed as a unit. An assembly is the primary building block of a .NET Framework application. All managed types and resources are contained within an assembly and are marked either as accessible only within the assembly or as accessible from code in other assemblies. Assemblies also play a key role in security. The code access security system uses information about an assembly to determine the set of permissions that is granted to code in the assembly.
Assembly name: The name of a collection of one or more files that is versioned and deployed as a unit
Collaborative Application Markup Language (CAML): An XML-based language that is used to describe various elements, such as queries and views, in sites that are based on Microsoft® SharePoint® Products and Technologies.
Content database: A database that is stored on a back-end database server and contains stored procedures, site collections, and the contents of the site collections.
Content type: A named and uniquely identifiable collection of settings and fields that store metadata for individual items in a SharePoint list. One or more content types can be associated with a list, which restricts the contents to items of those types.
Custom action: An extensible user interface component that is defined or deployed as part of a feature.
Event host: A site collection, site, list, list item, workflow, feature, or content type that hosts an event receiver.
Event receiver: A structured modular component that allows built-in or user-defined managed code classes to act upon objects, such as list items, lists, or content types, whenever specific triggering actions occur.
Feature: A package of Windows SharePoint Services 3.0 elements that can be activated or deactivated for a specific feature scope.
Field: (1) An element or attribute in a data source that can contain data. (2) A container for metadata within a SharePoint list and associated list items. (3) A discrete unit of a record that has a name, a data type, and a value.
Ghosted: The condition of a document whose content is stored in a location other than the content database. If a document is ghosted, the front-end web server determines the location of the content by using the SetupPath value for the document.
Host header: An Internet host and port number that identifies a network resource.
Host name: The name of a physical server
HTTP GET: An HTTP method for retrieving a resource
HTTP HEAD: An HTTP method for retrieving header information for a resource
List template: An XML-based definition of list settings, including fields and views, and optionally list items. List templates are stored in .stp files in the content database.
Master page: An ASP.NET file that has a predefined layout that can include static text, HTML elements, and server controls.
Site collection: A set of websites that are in the same content database, have the same owner, and share administration settings. A site collection can be identified by a GUID or the URL of the top-level site for the site collection. Each site collection contains a top-level site, can contain one or more subsites, and can have a shared navigation structure.
Site collection administrator: A user who has administrative permissions for a site collection.
Site collection identifier: A GUID that identifies a site collection. In stored procedures, the identifier is typically @SiteId or @WebSiteId. In databases, the identifier is typically SiteId/tp_SiteId.
Site definition: A family of site definition configurations. Each site definition specifies a name and contains a list of the site definition configurations. See also site definition configuration.
Site template: An XML-based definition of site settings, including formatting, lists, views, and elements such as text, graphics, page layout, and styles. Site templates are stored in .stp files in the content database.
Stored procedure: A precompiled collection of SQL statements and, optionally, control-of-flow statements that are stored under a name and processed as a unit. They are stored in a SQL database and can be run with one call from an application. Stored procedures return an integer return code and can additionally return one or more result sets.
Subsite: A complete website that is stored in a named subdirectory of another website. The parent website can be the top-level site of a site collection or another subsite. Also referred to as subweb.
Unghosted: (1) A document that has its content stored in the content database instead of the front-end file system. (2) A column or content type for which the schema is stored in the database instead of the front-end file system
Web application: (1) A container in a configuration database that stores administrative settings and entry-point URLs for site collections. (2) A software application that uses HTTP as its core communication protocol and delivers information to the user by using web-based languages such as HTML and XML.
Web Part: A reusable component that contains or generates web-based content such as XML, HTML, and scripting code. It has a standard property schema and displays that content in a cohesive unit on a web page.

 

Access/Create folders using WMIObject in PowerShell Script

function PS-CheckFolderExist($rootDrive,$rootFolder,$subFolder,$childFolder)
{
$disks = Get-WMIObject Win32_LogicalDisk -filter "DriveType=3" | Select DeviceID
foreach($disk in $disks)
{
 $deviceID = $disk.DeviceID;
 #write-host $deviceID
 if($rootDrive -eq $deviceID)
 {
  $mypathRoot=$rootDrive+"\"+$rootFolder+"\"+$subFolder+"\"+$childFolder
  if (test-path $mypathRoot -PathType Container)
  {
   write-host $mypathRoot "folder already exists!" -ForegroundColor Green
  }
  else
  {
   $mypathLevel1=$rootDrive+"\"+$rootFolder+"\"+$subFolder
   if (test-path $mypathLevel1 -PathType Container)
   {
    try
    {
     New-Item -path $mypathLevel1 -Name $childFolder -ItemType Directory
     write-host ""
     write-host $mypathLevel1"\"$childFolder "folder created..." -ForegroundColor Green
    }
    catch
    {
     write-host "Directory not available !..Please try again" -ForegroundColor Red
    }
   }
   else
   {
    $mypathLevel2=$rootDrive+"\"+$rootFolder
    if (test-path $mypathLevel2 -PathType Container)
    {
     try
     {
      New-Item -path $mypathLevel2 -Name $subFolder -ItemType Directory
      write-host ""
      write-host $mypathLevel2"\"$subFolder "folder created..." -ForegroundColor Green
     
      New-Item -path $mypathLevel2\$subFolder -Name $childFolder -ItemType Directory
      write-host ""
      write-host $mypathLevel2\$subFolder"\"$childFolder "folder created..." -ForegroundColor Green
     }
     catch
     {
      write-host "Directory not available !..Please try again" -ForegroundColor Red
     }
    }
    else
    {
     try
     {
      $mypathLevel3=$rootDrive+"\"+$rootFolder
      write-host $mypathLevel3
      New-Item -path $mypathLevel3 -ItemType Directory
      write-host ""
      write-host $mypathLevel3 "folder created..." -ForegroundColor Green
      New-Item -path $mypathLevel3 -Name $subFolder -ItemType Directory
      write-host ""
      write-host $mypathLevel3"\"$subFolder "folder created..." -ForegroundColor Green
      New-Item -path $mypathLevel3\$subFolder -Name $childFolder -ItemType Directory
      write-host ""
      write-host $mypathLevel3\$subFolder"\"$childFolder "folder created..." -ForegroundColor Green
     }
     catch
     {
      write-host "Directory not available !..Please try again" -ForegroundColor Red
     }
    }
   }
  }
 }
 else
 {
  write-host $rootDrive "drive is not available !..Please try again" -ForegroundColor Red
 }
 
}
}

PS-CheckFolderExist "C:" "iTest" "myPower" "log"

This example will create folders like below if doesnot exists!

C:\iTest\myPower\log

Thursday, July 19, 2012

SharePoint 2013 Beta is Ready Now!!!

Finally, Microsoft released SharePoint 2013 beta version. Click here to get more knowledge on SharePoint 2013.

Happy learning SharePoint 2013!

"Sorry to keep you waiting" - by Microsoft SharePoint 2013

Sample sites:

Monday, July 02, 2012

Windows Power Shell Command Builder

Are you worry about how to create/modify Power Shell Script? here is the place where you can play arround it!

http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.html

How easy is it?

Keep restarted Windows Server 2008 R2 Trail Version in exact after 1 hour!

I was working Windows Server 2008 R2 Trail Version for my learning . Suddenly, after few months one day my system got restarted without any intimation.Then I thought it could be some problem in my system.So again I re-started my system and keep working...then after exact 1hour again my system got restarted!!! I was just wondering what could be the reason behind this issue...Then I started search in google finally I found the reason for my problem using below option:

Click Run > Start then type slmgr.vbs -dli and click OK. Be patient after clicking OK because it will take some time before it will show you a Windows Script Host message window that says how much time you have remain.

Reason is simple "My Trail Version of Windows Server 2008 R2 got Expired",when your trail version got expired your window screen turn to black.

CSS: Word-Wrap Property

Most of the Web Application Developer might come accross while developing their applications/projects with Data Controls (DataGrid , DataView and etc...) a long word needs to be break onto next line.To overcome this issue you might have option to go with <div> control with scrolls, but output of this could be end with the design issue!!

To handle this situation just add "word-wrap: break-word;" CSS property of the particular control.

Thats it.Job done!

References:
http://www.w3schools.com/cssref/css3_pr_word-wrap.asp
http://www.impressivewebs.com/word-wrap-css3/
http://webdesignerwall.com/tutorials/word-wrap-force-text-to-wrap