Code (25)

08-11-2012 Recursive Query Parent Child Concatenation
25-04-2012 Change or remove filter / filter content from Sharepoint list / library view columns
20-04-2011 Sigin as different user in using Windows authentication
26-01-2011 Powershell CmdLets
30-05-2010 Update Statistics - Query to find tables and index number of statistics being old
15-03-2010 Passing encrypted data between JavaScript and C#
12-02-2010 Sharepoint - SPWeb.Groups Vs SPWeb.SiteGroups
28-01-2010 Accessing JD Edwards Data on iSeries or AS/400 from a ASP.NET / SQL Encoding / Error problem
28-01-2010 Controls not functional after Export to Excel or Export to PDF of Telerik in Sharepoint Application page
05-10-2009 ASP.NET Cannot open log for source {0}. You may not have write access. - Access is denied
28-08-2009 CRM - The SELECT permission was denied on the object 'BuildVersion', database 'MicrosoftCRM_MSCRM', schema 'dbo'
22-08-2009 CRM - Retrieve Cultures information from CRM into your Custom Web Application
21-08-2009 CRM - Globalization / Localization in Custom Web Application
19-08-2009 CRM - Do you want to save this file? Blank.aspx?
18-08-2009 CRM Exception - Microsoft.Crm.Application.Platform.Report. InternalCreate(String xml)
18-08-2009 CRM Exception - Microsoft.Crm.Reporting.SRSReport.convertDataSource()
24-06-2009 Oracle SQL Developer - Unable to create an instance of the Java Virtual Machine
27-01-2009 Detecting Idle time or Inactivity in Windows Forms
23-01-2009 PasswordChar and Set focus on page load for ToolStripTextBox
21-01-2009 Capture Form Close Event
21-01-2009 Richtextbox or multiline textbox and AcceptButton to handle Enter or Tab key press
21-01-2009 Key Combination shortcuts in C# Windows Form
01-01-2009 Convert string to hexadecimal and hexadecimal to string
31-12-2008 Implementing Transaction in Stored Procedure
31-12-2008 Implementing Transaction in .NET
Thu 8 Nov 2012

If you want to show records (Parent Child concatenation), then following SQL Server recursive query could help you in achieve. For a clear picture have a look at following snap



Recursive Query showing only child Records


with parentChildResult as


       select ItemId,



                     cast('' as nvarchar(max)) as ParentNames

       from Items

       where ItemCategoryId is null

        union all

        select i2.ItemId,



                     parentChildResult.ParentNames + ' > ' + parentChildResult.ItemDescription

       from Items as i2

       inner join parentChildResult

              on parentChildResult.ItemId = i2.ItemCategoryId


 select ItemId,

              stuff(ParentNames, 1, 3, '') + ' > ' + ItemDescription as ParentNames

from parentChildResult

 where ItemId in


       SELECT i.ItemId FROM Items i

       WHERE NOT EXISTS(SELECT 1 FROM Items I2 WHERE i.ItemId = I2.ItemCategoryId)



order by ParentNames



Recursive Query showing All parents and Child Records


with parentChildResult as


       select ItemId,



                     cast('' as nvarchar(max)) as ParentNames

       from Items

       where ItemCategoryId is null

        union all

        select i2.ItemId,



                     parentChildResult.ParentNames + ' > ' + parentChildResult.ItemDescription

       from Items as i2

       inner join parentChildResult

              on parentChildResult.ItemId = i2.ItemCategoryId


 select ItemId,

              stuff(ParentNames, 1, 3, '') + ' > ' + ItemDescription as ParentNames

from parentChildResult

 order by ParentNames


E-mail this post to someone or Comments here
Wed 25 Apr 2012

In sharepoint, if it is required to disable the filter and to keep only the sorting, then following workaround could be the solution one.
(Following change are done to sharepoint 2010 using sharepoint designer 2010, might be it works for 2007 aswell)

Please keep the copy of file(s) which you are going to change, incase if some mishap happen J

·         Open the desired sharepoint site in sharepoint designer

·         Select Lists and Libraries from the Site Objects

·         Select desired list / library

·         Select the desired view from the views list where you want to remove to remove filter

·         Click on advance mode

·         Search for the <ViewFields> inside <XmlDefinition>

·         Now add following desired attribute to all desired columns. (All column are  <FieldRef Name="ModifiedOn" />)


 <FieldRef Name=" ModifiedOn " LinkToItem="TRUE" Filterable="FALSE" FilterDisableMessage="No filter available "/>

After that, edit the page where the list / library webpart exists or add webpart (list / library) if not already added on the page,  edit webpart properties and select the desired view again then click apply button to reflect changes.


In above,

·         You can change the default text for disabled filter using FilterDisableMessage="No filter available " attribute

·         By adding Filterable="FALSE", now the filter will not be available

·         If you want to make a particular column clickable, then add LinkToItem="TRUE"


E-mail this post to someone or Comments (1)
Wed 20 Apr 2011

If you want to have signin as different user functionality like sharepoint in your application, following workaround you might be looking for.
After setting your web.config file's 

<authentication mode="Windows" />

and in IIS after remove anonymous authentication and enable windows authentication, have following code snippet where you want to have this functionality

In your aspx page

    <div>You are logged in as <br /> <%=User.Identity.Name%> <br /><br /> 
    <asp:LinkButton ID="lnkSignOut" runat="server" Text="Sign in as different user" onclick="lnkSignOut_Click"></asp:LinkButton>

In your code behind file

 protected void Page_Load(object sender, EventArgs e)
    if (!this.IsPostBack)
        Session["logOutRequested"] = false; //Initialize value. This will be set to true when user will click on sign in as differnet user

void lnkSignOut_Click(object sender, EventArgs e)
    if (null != Session["logOutRequested"] && !Convert.ToBoolean(Session["logOutRequested"])) // Check if user is clicking link first time
        Session["logOutRequested"] = true; //Set value that user want to sign in as differnet user
        Response.StatusCode = 401;
        Response.StatusDescription = "Unauthorized";
        Session["logOutRequested"] = false; //Initialize value again after user is authenticated with differnet or same user again.

Hope this workaround will help.

In case if above workaround is not working, you may try following one




Tags: , ,
E-mail this post to someone or Comments (1)
Wed 26 Jan 2011

Get-SPSite | where {$_.url -like "http://a *"}

Get-SPFarm | Format-List Id, BuildVersion, Servers, Solutions

Add-PSSnapin Microsoft.SharePoint.Powershell


ExecuteHelloWorldScript from batchfile

powershell -Command "& {.\Hello.ps1}" -NoExit

powershell -Command "& {Set-ExecutionPolicy bypass}" -NoExit



if($args) {
  $SiteName = $args[0]
  $SiteUrl = "http://a:3811/sites/ " + $SiteName
  Write-Host "Begin creating Contoso site at" $SiteUrl
  $NewSite = New-SPSite -URL $SiteUrl -OwnerAlias Administrator -Template STS#1 -Name $SiteName
  $RootWeb = $NewSite.RootWeb
  $RootWeb.Title = "Contoso Site: " + $SiteName
  Write-Host "New Contoso site successfully created"
  Write-Host "-------------------------------------"
  Write-Host "Title:" $RootWeb.Title -foregroundcolor Yellow
  Write-Host "URL:" $RootWeb.Url -foregroundcolor Yellow
  Write-Host "ID:" $RootWeb.Id.ToString() -foregroundcolor Yellow
Else {
  Write-Host "ERROR: You must supply Name as parameter when calling CreateContosoSite.ps1"



$path = "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14"

Get-ChildItem $path -recurse |
  Where-Object {$ -like "*SharePoint*.dll"} |
  Sort-Object -Property Name -unique |
  Format-Table Name



Get-SPFeature -Limit ALL |
  Where-Object {$_.DisplayName -like "*Publishing*"} |
  Sort-Object -Property Scope
  Format-Table DisplayName, Id, Scope



Get-SPFarm | Format-List
Get-SPSite | where {$_.url -like "http://a *"}
.\CreateContosoSite.ps1 lab01test


E-mail this post to someone or Comments here
Sun 30 May 2010

Query to find all the Tables and Index with number of days statistics being old. Then run Update Statistics command to update statictics for optimized query plan.

OBJECT_NAME(A.object_id) AS Object_Name, AS index_name,
STATS_DATE(A.OBJECT_ID, index_id) AS StatsUpdated ,
getdate()) DaysOld
FROM sys.indexes A
INNER JOIN sys.tables B ON A.object_id = B.object_id


E-mail this post to someone or Comments here
Mon 15 Mar 2010

This post posted by Vladimir Kuzin on 15th Oct 2009. For Quick reference posted here.

Few weeks ago I was working on project which required data to be encrypted using C# and then decrypted using JavaScript. In my case JavaScript was an internal scripting language, which wasn’t exposed to public so I didn’t have to worry about people accessing encryption keys. Project objective was to encode parameter in URL preventing users from substituting it with sequential numbers.


At first I’ve decided to use symmetric algorithm and looked online for available JavaScript libraries. In my search I’ve found few AES libraries to choose form. After further analysis it was determined that most people had good luck with slowAES, and I’ve attempted to implement it. After spending some time I was unable to decrypt any data encoded with RijndaelManaged class in C#. Since I had to find solution fast I’ve moved on.

Next I’ve decided to try asymmetric encryption algorithm, and after quick research I went with RSA. After downloading most popular RSA library for JavaScript I’ve run into several issues with its implementation. I was able to use C# to decode everything what was encoded in JavaScript, but it didn’t work when data was flowing in opposite direction. After looking into the issue it appeared that JavaScript library was missing padding, however using patched versionof the library didn’t help.


Due to lack of time I’ve decided to use simpler encryption algorithm and went with RC4. After downloading RC4 JavaScriptlibrary I’ve got it to work within minutes. Since there is no such thing as RC4 cryptographic provider in the Security.Cryptography namespace I had to use open source RC4 library.

After encrypting data I’ve also converted it to hex (base 16) in the same way as it was done on the JavaScript RC4 demo page.

Encrypting URL parameter with RC4 didn’t completely meet the objective, since it still was possible for users to use sequential numbers. Take a look at example of encrypted data below:

Input Output
10001 49845da1c0
10002  49845da1c3

Notice that only last digit of the encrypted data has changed, therefore substituting it with sequential numbers will cause an issue. To solve this I’ve added random prefix and suffix blocks to data before encrypting. Prefix and suffix blocks consisted from random letters and were anywhere between 10 and 25 characters in length. Now data looked like this:

32e523ddb00fbf2465002bc1b4251dd12876677d47d6a 6a3101a68517dfb6a86fa525139300d65225e365a38

Every time encrypted value is changing, since it’s generated from new random data. After transferring and decrypting this data on the JavaScript side I’ve spited string by semicolon to get the actual parameter value.

I am sure there are different and possibly better solutions somewhere out there, but this one worked for my client and was implemented within a small project budget.

This is post is from original Post @


Tags: , ,
E-mail this post to someone or Comments (3)
Fri 12 Feb 2010

SPWeb has two sharepoint cross-site group collection, SPWeb.Groups and SPWeb.SiteGroups.

SPWeb.Groups returns collection of cross-site groups which has some permission on the site. So if you add group from a site without any permission on the site, then this group wont appear in SPWeb.Groups collection, but it will appear in SPWeb.SiteGroups collection.

You can not use SPWeb.Groups.Add method to add new cross-site group, you need to use SPWeb.SiteGroup.Add method for this purpose.

In addition to this SPWeb has a property AssociatedOwnerGroup, which will return the required SPGroup. You can iterate the SPGroup users to get the list of all owners of the site.

 foreach (SPUser user in web.AssociatedOwnerGroup.Users)
      // .. list all the users                        


Finding and adding group

SPGroup  group = GetSiteGroup(web, "groupName");
if (null == group)
 web.SiteGroups.Add("groupName", web.AssociatedOwnerGroup, null, "Test Group description");


private static SPGroup GetSiteGroup(SPWeb web, string name)
    foreach (SPGroup group in web.SiteGroups)
 if (group.Name.ToLower() == name.ToLower())
     return group;
 return null;



Tags: , ,
E-mail this post to someone or Comments here