Thursday, June 3, 2010

Get loginname of the Sharepoint user with username efficently

Share/Save/Bookmark

If you wonder how to get login name with user name programmatically in SharePoint then you are reading the right post.
We can do this by looping all the users of web and get the spuser that matches with the username or by simply using SPFieldUserValue like below,
using (SPSite site = new SPSite("http://sharepointcustomization.blogspot.com/"))
{
using (SPWeb web = site.OpenWeb())
{
SPFieldUserValue userValue = new SPFieldUserValue(web, "UserName");
if (userValue.User.LoginName == web.CurrentUser.LoginName)
{
//do something!
}
}
}

Subscribe

Saturday, May 1, 2010

Unable to retract/delete/deploy the Sharepoint solution

Share/Save/Bookmark

These days i have had hard time of retracting a solution to deploy a new version of it.
Although i have tried manually and through stsadm/code the solution retraction never completes and gives the status as retracting forever. i have jotted down some workarounds that might work when Solution deployment hungs while deploying a solution :

- Run execadmsvcjobs that will forcefully run the timer jobs
stsadm -o execadmsvcjobs
- Delete the eixsting timer job for the retraction and retry retracting
From UI central admin -> operations -> Time Job Definitions ->click on timer job and delete. For the timer jobs that do not have the delete option enabled stsadm utility can be used,  
stsadm -o deletesptimerjob -title -id
To get the job id for the timer try the following
stsadm -o enumssptimerjobs
- If running out of options then stop retracting and delete the solution using override
stsadm -o deletesolution -filename -override


Subscribe