16 February 2017

SSIS & MS Dynamics CRM using Kingsway

Connecting to the CRM entities for loading or fetching data would be the tedious job if done from scratch, Kingsway ( Download from here ) came up with an intermediate connector to help or streamline the connectivity.
(1) Installed the Visual Studio (BITS) for BI development ( Download from here )
(2) Install the Kingsway SSIS Integration Toolkit for Microsoft Dynamics 365( Download from here )
(3) DataBase Driver which needs to be connected for data pull/push (SQL/ORACLE/MYSQL etc.)

Now we have the development environment set let connect to data sources:

For CRM connection:
(1) Right click on the connection manager
(2) Select new Connection
Select Type Dynamics CRM  (as Shown below)
Provide needed CRM URL and the Organization name 
Drop the Data Flow Task to perform needed BI operation
Within data Flow Task you will observe 3 new tool items added for dynamics CRM as shown below
Select desired based on the business needed, here I've selected as source which has the needed source type as an entity-entity name (source Entity)

For any further details please don't hesitate to drop an comment happy to respond 

08 February 2017

SSIS Script Task : ConnectionString for ADO.Net & OleDb ConnectionManager

In the switching world developer often needs to toggle between connection managers and wish the code operates as its expected.However, the execution engine is yet to be smart enough to undertake the difference.
Connection Manager TypeConnection Manager Name
ADOADO Connection Manager
MSOLAP90Analysis Services Connection Manager
EXCELExcel Connection Manager
FTPFTP Connection Manager
HTTPHTTP Connection Manager
ODBCODBC Connection Manager
OLEDBOLE DB Connection Manager

For those pin point here a code that worked for me and happy if works for you as well.
FOR ADO.NET Connection Manager

SqlConnection sConnection = new SqlConnection();
sConnection = (SqlConnection)(Dts.Connections["MyConnectionManagerADO.NETName"].AcquireConnection(Dts.Transaction) as SqlConnection);
var connection = sConnection.ConnectionString.ToString()

FOR OLEDB Connection Manager

var oConnection = Dts.Connections["MyConnectionManagerOLEDBName"].ConnectionString.ToString().Trim();
oConnection = oConnection.Replace("Provider=SQLNCLI10.1;", "").Replace("Provider=SQLNCLI11;", "").Replace("Provider=SQLNCLI11.1;", "").Replace("Auto Translate=False;", "");

31 December 2016

SSIS Exception Handling via script task C#

Writing a 'Script task' with c# code behind is a walk in the park, however, when the package is scheduled as Job the exception handling is vital key.
There are various permutations needs c# script is included to have needed outcome achieved.
Here is code snippet which can be included either in Catch block of try catch or as success/ failure condition as logic demands

{//your Code logic
catch (Exception ex)
Dts.Events.FireError(0, "- FAILED.", string.Concat("Oops! -", ex.Message.ToString(), "Inner Exception -",ex.InnerException.ToString() ), null, 0);
Dts.TaskResult = (int)ScriptResults.Failure;

09 March 2015

Elegant way to SWITCH & If Else

Switch Case is one of the most traditional way of having conditional break up performed. Here is the new way which directs, delegates and performs the action as needed.

Ideally I have seen developer opting for If Else statements, adding my source code were I need to set a check bit based on the parameter Range.

int mynumbercheck=1000;
//Your number to be checked
var myswitch = new Dictionary <Func<int,bool>, Action>
             { x => x < 10 ,    () => //Do this!...  },  
             { x => x < 100 ,    () => //Do this!...  },
             { x => x < 1000 ,    () => //Do this!...  },
             { x => x < 10000 ,   () => //Do this!... } ,
             { x => x < 100000 ,  () => //Do this!... },
             { x => x < 1000000 ,  () => //Do this!... } 
Now to call our conditional switch

   myswitch.First(sw => sw.Key(mynumbercheck)).Value();

Hope this Help you and reduces if else code block

20 December 2014

Fetch Application Pool Identity

Web Application requires the database operation to be performed by service account which is configured in AppPool.
When ever the user hits the web application the request is received at IIS and CRUD operation is performed against database.

Here's my code snippet to have transaction performed by APPPool Identity

Add this code

using System.Runtime.InteropServices;
using System.Security.Principal;

private static WindowsIdentity _appPoolIdentity;
public static WindowsIdentity AppPoolIdentity
   get { WindowsIdentity result;
         if (_appPoolIdentity != null){result = _appPoolIdentity;}
         else {result = (_appPoolIdentity = GetAppPoolIdentity());}
         return result;

[DllImport("advapi32.dll", SetLastError = true)]
private static extern bool RevertToSelf();
private static WindowsIdentity GetAppPoolIdentity()
       WindowsIdentity identity = null;
       Win32Exception win32Exception = null;
       Thread thread = new Thread(delegate(object o)
if (!Config.RevertToSelf())
       int lastWin32Error = Marshal.GetLastWin32Error();
       win32Exception = new Win32Exception(lastWin32Error);
  identity = WindowsIdentity.GetCurrent();
if (win32Exception != null)
       throw win32Exception;
return identity;

From your code just call the

       //your Execution Block under AppPool Id

Hope this Helps you

09 September 2014

SQL Server Query :Sort Ordering Query

Sorting and re-ordering is one of the most common requirement in today's demanding industry and there are many approaches to achieve the same.

Here I'm sharing one of the easiest back-end solution to over come re-Ordering from database function/Store Procedure.

The advantage of having a database driven ordering would help is saving the processing call from application to database, & can have control over the functionality at ease.

Below shows the ordering after removing few titles.

 Current Ordering
Title -- Order
Link 01-- 1
link 02 -- 2
link 03 -- 4
link 04 -- 6
link 05 -- 7
link 06 -- 8

To have current order in place we can have a database Function create to get corrected Ordering update to table /Column.

SQL function :  ROW_NUMBER()

Creating Code Block to get needed Ordering :
SELECT Title,SortOrder,
FROM dbo.tablename

ROW_NUMBER needs to have Over followed ORDER BY attributes


(a) Create a With Block
(b) Update with join on WITH black

WITH Correct_SortOrder AS
SELECT Title,SortOrder,
FROM dbo.tablename

Hope this Help you. Happy Coding :)

26 September 2013

Failed to initiate the upgrade sequence. An exception of type System.IO.IOException was thrown.

"Failed to upgrade SharePoint Products."

I have installed the office web app patch & re-run the configuration wizard when I encountered this exception 

Please Note the GUID is vital for clearing cache.

  1. Stop the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click SharePoint 2010 Timer, and then click Stop.
    3. Close the Services console.
  2. On the computer that is running Microsoft SharePoint Server 2010 and on which the Central Administration site is hosted, click Start, click Run, type explorer, and then press ENTER.
  3. In Windows Explorer, locate and then double-click the following folder:
  4. %SystemDrive%\ProgramData\Microsoft\SharePoint\Config\GUID
  5. Notes
    1. The %SystemDrive% system variable specifies the letter of the drive on which Windows is installed. By default, Windows is installed on drive C.
    2. The GUID placeholder specifies the GUID folder. There may be more than one of these.
    3. The ProgramData folder may be hidden. To view the hidden folder, follow these steps:
      1. On the Tools menu, click Folder Options.
      2. Click the View tab.
      3. In the Advanced settings list, click Show hidden files and folders under Hidden files and folders, and then click OK.
      4. You can also simply type this directly in the path if you do not want to show hidden files and folders.
  6. Back up the Cache.ini file. (Make a copy of it. DO NOT DELETE THIS FILE, Only the XML files in the next step)
  7. Delete all the XML configuration files in the GUID folder (DO NOTE DELETE THE FOLDER). Do this so that you can verify that the GUID folders content is replaced by new XML configuration files when the cache is rebuilt.
    Note When you empty the configuration cache in the GUID folder, make sure that you do NOTdelete the GUID folder and the Cache.ini file that is located in the GUID folder.
  8. Double-click the Cache.ini file.
  9. On the Edit menu, click Select All.
  10. On the Edit menu, click Delete.
  11. Type 1, and then click Save on the File menu. (Basically when you are done, the only text in the config.ini file should be the number 1)
  12. On the File menu, click Exit.
  13. Start the Timer service. To do this, follow these steps:
    1. Click Start, point to Administrative Tools, and then click Services.
    2. Right-click SharePoint 2010 Timer, and then click Start.
    3. Close the Services console.
  14. Note The file system cache is re-created after you perform this procedure. Make sure that you perform this procedure on all servers in the server farm.
  15. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.
  16. Check in the GUID folder to make sure that the xml files are repopulating. This may take a bit of time.

18 July 2013

SharePoint-GridView & PeopleEditor control.

Developer usually invest much time when the control are sharepoint and binding data is not made straight forward.

Below is simple example to get SharePoint:PeopleEditor control in SPGridView Control on application page.

Step 01:  Add SPGridView control on Application /Webpart page.
Step 02:  Add needed columns in the Sp GridView
Step 03 : Add Sharepoint PeopleEditor column
Step 04:  Add Title Property in PeopleEditor with binded column from data source
 Ex: -   Title='<%# Bind("AUTHOR") %>'
Step 05: Add OnRowDataBound property in SPGridView
Ex : - OnRowDataBound="spGridViewRowEventHandler"
Step 06: Add your picker validate code to resolve the user/Author on databound.

protected void spGridViewRowEventHandler(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)
                PeopleEditor ppAuthor = (PeopleEditor)e.Row.FindControl("Control");
                string userid= ppAuthor.Title.ToString();
                 ppAuthor.CommaSeparatedAccounts =userid


That's it your control is done

21 March 2013

SharePoint People-picker Slowness

Recently my SharePoint portal seems to slowing from end user information entering. The User entry box people-picker was really taking forever to resolve name. The slowness was recorded across whole site collection and there was no customization involved which might have affected this issue.

In order to resolve this slowness following steps needs to be performed.
1. Execute following command on the WFE server.

 Stsadm–o setapppassword –password 

Please note - the password here is not the server.

2. Now execute following command on APP server.

Stsadm –o setproperty –pn peoplepicker -searchadforests –pv "forests:i.domain.com, Domain:i.domain.com" -url "http://Sharepointsite/"

This will do the trick. repeat same for Sub-site as well.

05 March 2013

SharePoint User Profile Synchronization.

SharePoint portals are tightly integrated with Active Directory and since SharePoint has a additional Database to maintain user profiling, However many times user alias names are shown inconsistent on welcome.ascx section For some it's show :
         first name , last name
         last name, first name 
 This means AD-Profile Synchronization is not enabled or not happening for some reasons.

Manually run following SharePoint PowerShell Command which synchronizes AD Accounts.

Get-SPUser –Web http://SharePointServer | Set-SPUser –SyncFromAD

Execute command for each Site collection to reflect these changes.  

15 February 2013

SharePoint Error :The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service

InfoPath forms are giving following exception when trying to activate or add any new workflow
“The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator.”

 Solution : 

As I checked for the found State Service was not started, in order to start this service go to:

  1. Central administration  
  2. Configuration Wizards 
  3. Click “Launch the Farm Configuration Wizard” 
  4. click  “Start the Wizard”

To confirm state services is started go to
1. Application Management >>
2. Manage service applications you will see the status. 

01 November 2012

Silverlight and SharePoint connection with MVVM

  BasicHttpBinding binding = new BasicHttpBinding();
                EndpointAddress Address = new EndpointAddress(new Uri("http:///_vti_bin/lists.asmx"));
                // Required to initialize variables        

                ListsSoapClient proxy = new ListsSoapClient(binding, Address);
                proxy.GetListItemsCompleted += new EventHandler(proxy_GetListItemsCompleted);
                //Define the parameters for the service call
                XElement query = new XElement("Query");
                XElement queryOptions = new XElement("QueryOptions");
                XElement viewFields = new XElement("ViewFields");


Handler :

void proxy_GetListItemsCompleted(object sender, GetListItemsCompletedEventArgs e)
            XDocument doc = XDocument.Parse(e.Result.ToString());

            var rst = from item in doc.Descendants(XName.Get("row", "#RowsetSchema"))
                      select new OpenTktValue
                          Column1 = item.Attribute("ows_Column1").Value.ToString(),
                          ColumnN = item.Attribute("ows_ColumnN").Value.ToString()

            rst.First().Column1.ToString() + "-" + rst.First().Column1.ToString());

04 October 2012

SharePoint 2010 -SVC service Exception :'System.Data.Services.Providers.IDataServiceUpdateProvider'

SharePoint 2010 has List data web service However many users trying to access get following exception :   http://yoursite/_vti_bin/ListData.svc

Could not load type 'System.Data.Services.Providers.IDataServiceUpdateProvider' from assembly 'System.Data.Services, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


Installation needed on SharePoint web front end servers: ADO.NET Data Services Update for .NET Framework 3.5 SP1 for Windows 7 and Windows Server 2008 R2

Click to Download -- ADO.NET Data Services Update for .NET Framework.

18 September 2012

Remove line with keyword from Text file :C#

Requirement : Huge text file needs to be parsed and the output file needs should eliminate
lines having special characters/words.

Solution: This is a 3 step solution : (1) reade file (2) Parse File with key word
(3) Output as required

Declare Source & Destination file - Setting parameter:

    string _SourceFile= @"c:\Sample_IN.txt";
    string _DestinationFile= @"c:\Sample_OUT.txt"; 

// Reading Source file

            string line =string.Empty; 
            StringBuilder StrBld= new StringBuilder();
            WrdFound = true; 
            //READ the file and display it line by line. System.IO.StreamReader
            file = new System.IO.StreamReader(filename); 
            while ((line = file.ReadLine()) !=
            { if (!(line)) 
            StrBld.AppendLine(line.Replace(' ',',')); 

//CHECK Key word against which the line to be dropped Ex my key words are "AKSHAYA"

            CheckKeyWord(string _eachLine) 
            if (_eachLine == null || _eachLine.Length
            == 0) return false; else 
            { Regex regex = new Regex(@"(AKSHAYA|MASHANKAR)", RegexOptions.IgnoreCase);
            return regex.IsMatch(_eachLine); } 


//WRITE the file and display it line by line.
 using (StreamWriter sw = new StreamWriter(tempFilename))

Please share your thoughts and comments for the dame

28 July 2012

SharePoint 2010 -MS LYNC Integration.

SharePoint - a collaborative platform to have mash up functional is always fun. Recently I found can across well drafted article published by J.D. Wade on Sharepoint and Microsoft Lync.

Lync and SharePoint Integration

Special thanks : J.D Wade.

21 July 2012

ORACLE : WITH Block statement

Query writing is fun but can be complex when we are referring multiple tables/views which has inlet/Joins /sub-query referred. on the best solution & organized way of writing such query in Oracle is using WITH Blocks.
Below I'm using simple example to help you get started with WITH-blocks
Tutorial : First block starts with "WITH" keyword  
WITH block_name AS ( ), Final statement includes Select statement with in query or join as needed treating each block as table. Below are 2 example showing with block usage.

Example : Consider 4 tables/views having needed information blinded with a connecting factor and say ID. Normal Query States :

        SELECT T1.Col1, T1.col2, T2.col3, T2.col4,
T2.col5 FROM Table1 T1 JOIN Table2 T2 ON Col6 = col7 
Now to have more organized way to get this query executed using WITH Block  

CONDITION 01: Using blocks in WHERE clause
  TableA TA JOIN TableB TB ON TA.COLA1 = tb.ColB1), 
SELECT T1.Col1, T1.col2, T2.col3, T2.col4, T2.col5 FROM Table1 T1 JOIN Table2 T2 ON Col6 = col7 WHERE col6 IN 
( --Note:with block added as select statement & can be used at multiple places. 
SELECT block1.cola FROM BLOCK1 

CONDITION 02: JOINING WITH blocks all together.
--Note : block starts from "WITH" statement
        WITH BLOCK1
TableB TB ON TA.COLA1 = tb.ColB1 
--Note: Except last with block all with block end with , 
SELECT T1.Col1, T1.col2, T2.col3, T2.col4, T2.col5 FROM Table1
T1 JOIN Table2 T2 ON Col6 = col7 
--final statement only includes Black name. 
SELECT * FROM Block2 B2, Block1 B1 WHERE B2.col6 = b1.COLA
Hope this help's you ----

14 March 2012

Power Shell Command finder links

Couple of helpful links for Powershell links to refer

SilverLight Command Builder

Index of SharePoint Server 2010 Windows PowerShell cmdlets

Codeplex PS tool (directions on the site)

Finally for Remote Server Execution of powershell commands best mentioned steps:
SharePoint 2010 with Windows PowerShell Remoting Step by Step

Hope this helps you as well.

04 March 2012

Central Administration returns blank page after installation on Windows 7

Installation of SharePoint 2010 on Windows Server seems to be much easier than installing on Windows-7 machine to be loaded with SharePoint 2010 as a developer machine.

Now when i click on central admin blank page is returned.
No Error logs in IIS.
However I checked IIS Web-site & Application Pool everything seems to be running fine & was registried with proper service account.
Also check all SQL & Sharepoint Service which were also properly started.

Overall there was really no way anything was missed.
However after long search and troubleshooting i found windows features are required to be executed Click here to check steps by MSDN

Following command needs to be executed on Command Prompt as administrator:

start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ManagementScriptingTools;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-RequestFiltering;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;WCF-HTTP-Activation;WCF-NonHTTP-Activation

Hope this help you too.

05 January 2012

Custom entry for Hyperlink Or Picture column in SharePoint using webpart

SharePoint provides many columns as input one of which is Hyperlink or picture column which has two fields as entry and is a concern how to have the entry to be made possible from custom web part or via custom coding.

Normal out of box form looks like this.

I have created a webpart which has needed input holder to accept values from user.
Currently I’m using 2 columns Title & Hyperlink column : MyURL for URL
Please find the code for the same.

using (SPSite osite = new SPSite(SPContext.Current.Web.Url))
using (SPWeb oweb = osite.OpenWeb())
SPList Samplelist = oweb.Lists["ListName"];
SPListItem ListItem= Samplelist.AddItem();
oweb.AllowUnsafeUpdates = true;
ListItem["Title"] = "Akshaya Blog Title";
SPFieldUrlValue HyperlinkURLVal = new SPFieldUrlValue();
HyperlinkURLVal.Url ="http://akshaya-m.blogspot.com";
HyperlinkURLVal.Description = "Akshaya Blog Click Here";
ListItem["MyURL"] = HyperlinkURLVal;
//Update List item

Outcome as needed--

Thanks please revert your queries/comments

16 December 2011

Validate Login User with AD/LDAP authentication(Login Page)

Validating users against Active Directory/ LDAP. Also many organisation have multiple domains and same application needs to validate accross all domain.

This code can be used in SharePoint custom Login form for user Validation for Claim based authentication or Form Based Authentication.

Reference Added :

using System.Runtime.InteropServices;

COMException : The exception that is thrown when an unrecognized HRESULT is returned from a COM method call for more simplified error response from LDAP Error: Unknown error (0x80005000).

using System.DirectoryServices;

Below is the code sniplet

using (DirectoryEntry entry = new DirectoryEntry())
entry.Username = "DOMAIN\\LOGINNAME";
entry.Password = "PASSWORD";
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(objectclass=user)";
//Add Your Code if user Found..
catch (COMException ex)
if (ex.ErrorCode == -2147023570)
// Login or password is incorrect

ErrorCode : -2147023570 suggest the Username or password is not correctly entered.

post your questions, comments or suggestion.

10 December 2011

Hide the extension .aspx in the url of page ...

Now a days customers are more concerned with site URL and its relative path displayed on the browser address.
Many Suggest having interceptor/handler or use the existing global.asax (Application_Begin Request handler) for modifying the URL shown in the browser window, Web Routing is the concept (4.0 framework)

However you can get solution for .Net /sharepoint application there are following ways:
  1. MVC
  2. HttpModule rewrite URL
  3. ISAPIRewrite to enable Extension-less URL Rewriting for IIS5 and IIS6
  4. IIS level extension parsing
Step by step approaches refer below links:
URL Rewriting in ASP.NET
URL Rewriting in Asp.net
URL rewrite/Routing (4.0 framework concept) *
IIS Forum for Extension parsing

 Let me know your comments /feedback for the same

16 August 2011

ASP .Net Page Life cycle

There are many post related to page life cycle. but the mentioned is really the best provided
Graphical View for Page Life Cycle

24 June 2011

Grid with Content Query Webpart

Here I'm sharing link to get Display Content Query Web Part Results in a Grid / Table well explained by Paul.
.Click here to view

17 February 2011

Sandbox Solution: Overview

What is sandbox solution

Sandbox is a restricted environment where programs are deployed with restrictions. It plays valuable role for developers to test their application by using sandbox solution. Once this is tested it can be later deployed to full use in the farm.

Solution that are deployed into sandbox are called sandbox solutions.

If farm is load balanced.
Release code which is fully not tested for production release.
Less bottleneck for farm administrator as this can be managed at site collection by administrator to it.

First decide whether you want this solution? as using this solution does has impact on performance of the servers. As the farm using sandbox does have more process load than a farm without this.
Code Access Security (CAS) limits the operations that the code can perform

How to use

Activate SharePoint 2010 User Code Host service(SPUCHostService.exe,)  on server you want this solution. Should be done by farm administrator

Sandbox Code Services

Sandbox can be applied at the root of site collection level.
Members of the site collection administrators group can deploy sandboxed solutions

Governance for sandbox

Before deploying think of below

When should the solution be blocked or unblocked?
When to release the solution to production?
Who should be given access, deployment rights etc?

Adding / Blocking /Load Balancing for Sandbox

This can be done via CA – System settings

Special Thanks :Amarprit Jaspal

26 January 2011

List of Content Managment Systems.

In today's world Content Management System is core requirement for a business oriented system more and more companies developing their business standard directly influencing the need for CMS to hand their operation.

For all CMS lovers here is consolidated list fro all the management systems present till dated.
Click Here  By Wiki

25 November 2010

WSP Process stuck in "Deploying"

Recently, I deployed my Webpart solution packages created in sharepoint Farm.
After a long waiting i still figured the solution getting "Deploying" as its status..
Initially i Tried

stsadm -o execadmsvcjobs on the server running Central Admin.  No change. 
Since it was a farm deployment i Thought improper deployment was performed.

so I reset the IIS to get a refreshed processes running but still no effect.

Solution: Not Sure if its correct but worked for me.I opened list of timer jobs (Operations > Timer Job Definitions) search the job which point to the WSP solution we are deploying..Killing the Process will do the Trick.

However this does not actually deploy but only status is populated as "Deployed".
To Overcome this solution since you are on Farm Servers you need to Execute stsadm -o execadmsvcjobs on all the servers

23 November 2010

SharePoint 2010 Database Naming Standards


Database Naming conventions for SharePoint 2010 well defined by John W Powell -Click Here to view!


15 November 2010

FBA : Change Password

From my Earlier blog stating Form Based Authentication in SharePoint (MOSS 2007).
 ( Click Here )

Many were interested in password management for the users. A complete package ready to use is uploaded on codeplex.
However here I’m attaching a custom strip down to users change Password code snippet for the same.

There are two options while password management
1. Just to change Password
2. to provide Question & Answer along with Password change
Note : for Option (2) please add/updated web.Config file within Membership provider

///save button functionlity
void btnChangePassword_Click(object sender, EventArgs e)
if (Validate(true))
string AppName = Membership.ApplicationName;
if (.Text.Trim().ToString() != .Text.Trim().ToString())
{ .Text = " New and Confirm password Mismatch ! " ; }
if (Membership.Provider.ChangePassword(.Text, .Text, .Text))
{ //membership provider has Change Password checked in Web.Config
if (Membership.Provider.ChangePasswordQuestionAndAnswer(.Text, .Text, .Text, .Text))
//Message: " Your Password Has Been Sucessfully Changed.."
catch (MembershipPasswordException ee)
{//Exception Message}


Let me know your comments/ exceptions etc.
Will be glad to get back to you.

Active Directory: Password Management using SharePoint Webpart.

For Active Directory member the password management is one of the vital functionality which developer needs to add in his efforts to provide a appropriate solution.
Here below is the code snipplet to achieve this functionality.

I have implemented using SharePoint Webpart.

please specify you validation accordingly.
-:Core Code:-

WindowsImpersonationContext aspContext = null;
WindowsIdentity identity = WindowsIdentity.GetCurrent();
aspContext = identity.Impersonate();
ContextOptions o = ContextOptions.Negotiate;
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, this._DomainName, this._DomainName Path);

UserPrincipal UPrinci = new UserPrincipal(ctx);
UPrinci = UserPrincipal.FindByIdentity(ctx, SPContext.Current.Web.CurrentUser.LoginName);
UPrinci.ChangePassword(_oldpassword.Text, _newpassword.Text);
_labelmsg.Text = "Password changed successfully!" ;
} //Try
catch (PasswordException ex)
{ //ex.Message; Catch exception.}
} //Delegate


Let me know your comments/ exceptions etc.
Will be glad to get back to you.

02 November 2010

SharePoint WebPart & ASP.Net Coding workarounds

As a SharePoint Developer there are couple of the changes in coding as compared to ASP.net application.
Few important note I would like add for my developer Friends

For Output : http://akshaya-m.blogspot.com?k=akshaya

Asp .Net Code
SharePoint Webpart Code Needs:

Get akshaya from the browser URL (http://akshaya-m.blogspot.com?k=akshaya)

Asp .Net Code
SharePoint Webpart Code Needs:

29 October 2010

SharePoint Excel Error: Unable to Load WorkBook

When trying to open a excel file many come across this exception stating :

"The workbook that you selected cannot be loaded because it contains the following features are not supported by Excel Services"

Many blog suggested for Excel Services Trusted Site Entry for the excel file referring.

However the solution that worked for me:

Give "Read permissions" to the users and they will be able to open the file using excel client.

Steps :
For more info on how to see permissions you have for users and groups in your site go to: Site Actions > Site Settings > Advanced Permissions.
Edit User Permissions to Read

Also make sure the permission are inherited to the Document Library permissions.

Revert with your Comments on the same.

12 October 2010

Warning: Super user account!

When Working on a farm environment couple of time we come across some warning stating:
"The super user account utilized by the cache is not configured...."

Temporary Solution
:: execute- 'stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl'.

Furthermore, there is the caveat:
The account should be any account that has Full Control access to the SharePoint databases but is not an application pool account. What have people done - create a special account?

After doing an extensive research i found solution as stated by Mirjam van Olst


07 October 2010

SharePoint Installation steps

For installing Sharepoint on your local system please refer this blog

Over view on Installing Sharepoint 2007by dataSprings

Over view on Installing Sharepoint 2010by SharePoint Knowledge

Custom Welcome Control

For providing enriched contents on the masterpage sharepoint has UserControls placed.

Here I'm providing couple of best link for the same.

20 July 2010

Create WebPart Properties with Drop Down Items.

Dealare field

protected WeekDays _daysWeek = WeekDays.Sun;

/// Days of the Week to be appended in the Dropdown List

public enum WeekDays
Tue, Web, Thur, Fri, Sat, Sun
/// Properties

[WebBrowsable(true)] [System.ComponentModel.Category("My Zone")]
[WebDisplayName("My DropDown Property")] [WebDescription("Get webpart properties
with DropDown")]
public WeekDays SelectedDay
{ return _daysWeek; }
{ _daysWeek = value; }

26 June 2010

Print WebPart Content Area :Sharepoint

After developing a business specific front end there is always a request for Print functionality for specific WebParts /content.

Here is a script added at SharePoint Forum (Click Here)

12 May 2010


1. List Creation:
Create two list in the web application which needs this functionality to be implemented.
  1. Category: create list named “CATEGORY “ with default Title field in it.
  2. Sub-Category: Create list named “SUB-CATEGORY” with Title & a lookup from the Category List (Title Column).
Script for Content Editor WP.
Note: For adding script get the List GUID and Default View GUID of the Sub Category List

<script type="text/javascript"> _spBodyOnLoadFunctionNames.push("PageOnLoad");
function PageOnLoad()
{ // This function will add onchange event to the Country DropDown field and call
OnChanged function. var lookupElement = GetElementByTypeAndTitle('SELECT','Category');
if ( lookupElement != null)
lookupElement.onchange = function()
} }
function OnChanged(FilterValue)
{ // siteName - the root / and possibly sub site you are working on
// lookupListName - the guid for the list you want to use as lookup
// lookupViewName - the guid for the view filtering the content of the list
// Open the List -> Settings -> List Settings -> Click on "All Items" view,
// From the URL you can get the ListName GUID and ListView GUID.
// textField - the field you want to show to the user
// valueField - this is most of the time the internal ID field
// FilterField - the field you want to be a filter
// FilterValue - the filter's value var
var lookupListName="{90533341-04F8-4353-BBEB-D6D9A0BAAC1F}";
var lookupViewName="{C6C467A6-C04D-448D-8015-D4A622784745}";
var FilterField ="Category";
var textField ="ows_LinkTitle";
var valueField ="ows_ID";
var filterElement = GetElementByTypeAndTitle('SELECT','Sub-Category');

filterElement.innerHTML = ""; var reqstring = siteName + "/_vti_bin/owssvr.dll?CS=109&XMLDATA=1&RowLimit=0&List=" + lookupListName +"&View=" + lookupViewName;

if (FilterValue != "") reqstring= reqstring +
"&FilterField1=" + escape(FilterField) + "&FilterValue1=" + escape(FilterValue);

var req = new ActiveXObject("MSXML2.XMLHTTP"); req.open("GET",reqstring,false);
// -- loading response in XML Document
var doc = new ActiveXObject("MSXML2.DOMDocument"); doc.loadXML(req.responseText); var data = doc.documentElement.childNodes(1);
for (i=0;i<data.childNodes.length;i++)
var optionText = data.childNodes(i).attributes.getNamedItem(textField).value;
var optionValue = data.childNodes(i).attributes.getNamedItem(valueField).value;
var opt = document.createElement("OPTION");

opt.innerText = optionText;
opt.value = optionValue;
} }
function GetElementByTypeAndTitle(elementType, elementTitle)
//get the Element by tag name.
var allElements = document.getElementsByTagName(elementType);
for (var i = 0; i < allElements.length; i++)
//compare the Title.
if (allElements[i].title == elementTitle) return allElements[i];
return null;

23 March 2010

Webpart :File Upload with Folder Drill Down

Development Steps:
Custom webPart is created for specific document library which populates folders and sub-folder ina dropdown control showing the folder name and file control to upload file to the selected folder/sub-folder.

1. Control initialization is carried in the CreateChildControls()
Note: since the control needs to pertain existing values in on page I referred I have enabled drop Down values true for
<DropDown_Control>.AutoPostBack = true;
<DropDown_Control>.EnableViewState = true;

2. Loading the Parent drop-down with all the parent Folders

using(SPWeb myWeb = mysite.OpenWeb())
//before selecting the Folder
ListItem listItem = new ListItem();
listItem.Text = "Select Folder";
listItem.Value = "";
myWeb.AllowUnsafeUpdates =true;
SPFolder mylibrary = myWeb.Folders[<Document Library Name>.ToString()];
SPFolderCollection AllFolders = mylibrary.SubFolders;
foreach (SPFolder folderin AllFolders)
listItem = new ListItem();
listItem.Text = folder.Name.ToString();
listItem.Value = folder.Name.ToString();
<DropDown Control_1>.Items.Add(listItem);


3. Loading the Child DropDown with-in the selected parent folders

void<DropDown Control_1>_SelectedIndexChanged(object
sender, EventArgs e)
//The code is much similar the mentioned above except few minor variations
using(myWeb = mysite.OpenWeb())
ListItem listItem = newListItem();
listItem.Text = "Select Sub-Folder";
listItem.Value = "";
<DropDown Control_2>.Items.Add(listItem);
myWeb.AllowUnsafeUpdates = true;
string_MainFolder = [<Document Library Name>.ToString();
SPFolder Mainlibrary = myWeb.Folders[_MainFolder];
SPFolder mylibrary = Mainlibrary.SubFolders[<DropDown Control_1>.SelectedValue.ToString()];
SPFolderCollection AllFolders = mylibrary.SubFolders;
foreach (SPFolder folder in AllFolders)
listItem = newListItem();
listItem.Text = folder.Name.ToString();
listItem.Value = folder.Name.ToString();
<DropDown Control_2>.Items.Add(listItem);

4. I have used a file upload control to get the local file to be uploaded

5. To upload my local file in the specified folder location selected on my Button control <Button_Control_Click Event>


void < Button_Control>_Click(object sender,
if(<FileUpload_Control>.PostedFile !=null)
if(<FileUpload_Control>.PostedFile.ContentLength > 0)
System.IO.Stream strm = <FileUpload_Control>.PostedFile.InputStream;

byte[] FileContent = new byte[ Convert.ToInt32(<FileUpload_Control>.PostedFile.ContentLength)];

strm.Read(FileContent, 0, Convert.ToInt32(<FileUpload_Control>.PostedFile.ContentLength));

// Open site where document library is created.
SPWeb myWeb = mysite.OpenWeb();

// Get the folder that should store the document In this case, there's a document library called "<Document Library Name>" within the Root Web of the Site Collection
SPFolder MainDocLib = myWeb.Folders[<Document Library Name>.ToString()];

// Within the "<Document Library Name>" library, add the document into its Parent Folder
SPFolder parent = MainDocLib.SubFolders[<DropDown Control_1>.SelectedValue.ToString()];

// Within the "<Document Library Name>" library, add the document into a Parent folder's Sub-Folder
SPFolder child =parent.SubFolders[<DropDown Control_2>.SelectedValue.ToString()];

// Upload document

myWeb.AllowUnsafeUpdates = true;

SPFile spfile = child.Files.Add(System.IO.Path.GetFileName(<FileUpload_Control >.PostedFile.FileName), FileContent,true);


<Status_Control>.Text = "File Successfully Uploaded! @"+ child.Url.ToString();
<Status_Control>.Text = "Sorry! File Not Found!";


Special Thanks: Dhawal Mehta

18 February 2010

Domain Specific Master Page/CSS Loading...

Having different Branding for alternate user is one of the most demanding requirement from a business prospective. However I have been incisive with the HTTP handler to load my masterpages for various domain based users..
Here is the simplest solution suggested & implemented by my friends which is really effective and fast to incorporate..
All my efforts were utilized in created CSS (style Sheet) and its adjacent master file..
These .CSS & .master file are uploaded on the portal’s style library.
For effective implementation I have added the following entries in the master page it self.
CSS initialization has been done in the head tag while domain checking and loading on masterpage is carried on the body.

If you want you can perform the same by using a content Editor Webpart Also.
/*.MASTER File/*


<link href="../../Shared Resources/custom.css" rel ="stylesheet" type ="text/css"
< link rel ="stylesheet" type ="text/css" title = "MasterStyle01" href =

< link rel ="stylesheet"type ="text/css" title = "MasterStyle02" href = "/Style Library/MasterStyle02.css" />


Body must include the conditions to check the User Domain and to load its corresponding master file.


<BODY scroll="yes" onload="javascript:if (typeof(_spBodyOnLoadWrapper) !=
'undefined') _spBodyOnLoadWrapper();">
<WebPartPages: contenteditorwebpart id="ContentEditorWebPart1" runat="server"
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2>
<Content xmlns ="http://schemas.microsoft.com/WebPart/v2/ContentEditor"> <! [CDATA[<script>
var myLoginUser = '_LogonUser_'.toLowerCase();
if (myLoginUser.indexOf('Domain01') != "-1")
for(var StyleSheetIterator = 0; StyleSheetIterator<document.styleSheets.length; StyleSheetIterator++)
if(document.styleSheets[StyleSheetIterator].title =="MasterStyle02")
{ document.styleSheets[StyleSheetIterator].disabled = false; }
if(document.styleSheets[StyleSheetIterator].title == "MasterStyle01") { document.styleSheets[StyleSheetIterator].disabled = true; }
</script>]]> </Content></WebPart> </WebPartPages:ContentEditorWebPart>

Note: check the tags existence in the master file itself before adding.
Special Thanks : Anshul Gagneja & Dhawal Mehta

Rate Now: