Friday, November 19, 2010

appcmd.exe location path


appcmd list wp

Wednesday, November 17, 2010

Sharepoint 2010 Get claim username and claim object for username

Get claim username
string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;

Get claim object:
string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
SPClaim claim = new SPClaim(SPClaimTypes.UserLogonName, "myuser", "", SPOriginalIssuers.Format(SPOriginalIssuerType.Forms, "myprovider"));
userName = mgr.EncodeClaim(claim);

Wednesday, November 3, 2010

SharePoint 2010 Web Application Service Unavailable - New User Password

I recently encountered the "Service Unavailable" issue on my dev machine. I looked high and low for a solution and eventually i figured out that it was because the password of my service account had changed (the same account i log into my machine with).

So all u need to do is update the password and restart the app pool.

1. Run SharePoint 2010 Management Shell as Administrator
2. Enter the following cmdlet: Set-SPManagedAccount -UseExistingPassword
3. Enter your current username , then provide your new password.
4. Go to IIS, refresh your app list and start the stopped application.
5. Should be sorted now.

Hope that saves someone from the frustration i had.

Monday, November 1, 2010

SharePoint 2010 Impersonate Workflow

Ive been getting some workflow problems lately in that when a user adds an item thats supposed to kick off a workflow, the workflow fails before start or while its in progress with "access denied" or "unauthorised access".

At first i couldnt understand this because MSDN documentation clearly states that workflow by default executes as system account / administrator.

I found out that the problem had to do with the fact that these users who were getting these problems were in a permissions group that prevented editing. For some reason, this permission is required to KICK OFF a workflow.

So the solution is to impersonate your workflow. In sharepoint designer 2010 click on the "Impersonation Step" icon which sits next to the "Step" icon in the workflow tab. This inserts an impersonation step. Every action you put into this step will be impersonated as the author of the workflow. So you just have to make sure that the author (you) has edit permissions on the list.

Make sure you move all the actions and condition blocks into your impersonation step and delete the old normal step. Then save and publish.

p.s. you can move the actions and condition blocks by clicking on the "Move Up" or "Move Down" links in the Workflow toolbar.