Keyword: User Profile Synchronization Service wont start
When configure user profile sync service, I get this error:
User Profile Application: SynchronizeMIIS encounters an exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Office.Server.UserProfiles.UserProfileImportJob.<>c__DisplayClass2.<IsTimerJobRunning>b__1()
at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
at Microsoft.Office.Server.UserProfiles.UserProfileImportJob.IsTimerJobRunning(UserProfileApplicationJob timerJob)
at Microsoft.Office.Server.Administration.UserProfileApplication.SynchronizeMIIS()
at Microsoft.Office.Server.Administration.ILMProfileSynchronizationJob.Execute()
This is because the FIM certificate has not been validated yet. The farm account which the sync service is running under must have access to Internet. This validation only needs to be done once, after the certificate is validated, you can disconnect Internet.
Wednesday, 17 September 2014
Thursday, 11 September 2014
Error: "Not able to connect to search service to retrieve valid settings"
I tried to change the query of the search results webpart and I've got this:
Fix is to use the SharePoint management Shell and define your account as an SSA Admin.
Here's the code to add yourself as SSA admin:
$principal = New-SPClaimsPrincipal "<domain>\<user>" -IdentityType WindowsSamAccountName
$spapp = Get-SPEnterpriseSearchServiceApplication
$security = Get-SPServiceApplicationSecurity $spapp –Admin
Grant-SPObjectSecurity $security $principal "Full Control"
Set-SPServiceApplicationSecurity $spapp $security –Admin
Fix is to use the SharePoint management Shell and define your account as an SSA Admin.
Here's the code to add yourself as SSA admin:
$principal = New-SPClaimsPrincipal "<domain>\<user>" -IdentityType WindowsSamAccountName
$spapp = Get-SPEnterpriseSearchServiceApplication
$security = Get-SPServiceApplicationSecurity $spapp –Admin
Grant-SPObjectSecurity $security $principal "Full Control"
Set-SPServiceApplicationSecurity $spapp $security –Admin
Wednesday, 23 July 2014
Link multiple EditForms or DisplayForms to a sharepoint list
My listitems are opened via an infopath form. Client wants a second aspx form to open the listitems.
(the infopath form only shows a subset of the fields but the aspx form shows all fields).
When opening the aspx form, sharepoint redirects me to the infopath form. Somewhere, a redirect was taking place.
After a lot experimenting, I found that not only do you need hide the original List Form Web Part but you also need to set the ControlMode to Display. Here are the 2 lines of code that need to be modified in the original List Form Web Part:
Change:
<ControlMode xmlns=”http://schemas.microsoft.com/WebPart/v2/ListForm”>Edit</ControlMode>
To:
<ControlMode xmlns=”http://schemas.microsoft.com/WebPart/v2/ListForm”>Display</ControlMode>
Change:
<IsVisible>true</IsVisible>
To:
<IsVisible>false</IsVisible>
Monday, 16 June 2014
SharePoint 2013 Chrome Control Options
Looking through SP.UI.Controls.Debug.js, here are the options:
siteTitle
siteUrl
clientTag
appWebUrl
onCssLoaded
assetId
appStartPage
rightToLeft
appTitle
appIconUrl
appTitleIconUrl
appHelpPageUrl
appHelpPageOnClick
settingsLinks
language
bottomHeaderVisible
topHeaderVisible
siteTitle
siteUrl
clientTag
appWebUrl
onCssLoaded
assetId
appStartPage
rightToLeft
appTitle
appIconUrl
appTitleIconUrl
appHelpPageUrl
appHelpPageOnClick
settingsLinks
language
bottomHeaderVisible
topHeaderVisible
Friday, 13 June 2014
Get List Field Internal Name
You can get the internal name for a column by browsing to the List Settings > Edit Column and look at the QueryString. This will be url encoded but is a simple way of retrieving the internal name without writing any code. You will get something like:
/_layouts/FldEdit.aspx?List=%7B37920121%2D19B2%2D4C77%2D92FF%2D8B3E07853114%7D&Field=Product%5Fx0020%5FDescription
%5F is a '_'. The field name is Product_x0020_Description.
The code option is to use:
string itemInternalName = item.Fields["Field Display Name"].InternalName;
Thursday, 12 June 2014
Different ways to get user name using javascript
Get user email
_spPageContextInfo.userLoginName
Using REST Service
$(document).ready(function () {
var userid = _spPageContextInfo.userId;
function GetCurrentUser() {
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
$.ajax({
url : requestUri,
contentType : "application/json;odata=verbose",
headers : requestHeaders,
success : onSuccess,
error : onError
});
}
function onSuccess(data, request){
//var loginName = data.d.LoginName.split('|')[1];
var loginName = data.d.Title;
alert(loginName);
}
function onError(error) {
alert(error);
}
GetCurrentUser();
});
Using JSOM
$(document).ready(function () {
var currentUser;
// Ensure that the SP.js is loaded
if (SP.ClientContext != null) {
SP.SOD.executeOrDelayUntilScriptLoaded(getCurrentUser, 'SP.js');
}
else {
SP.SOD.executeFunc('sp.js', null, getCurrentUser);
}
function getCurrentUser() {
var context = new SP.ClientContext.get_current();
var web = context.get_web();
currentUser = web.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(onSuccessMethod, onRequestFail);
}
function onSuccessMethod(sender, args) {
var account = currentUser.get_loginName();
var currentUserAccount = account.substring(account.indexOf("|") + 1);
alert(currentUserAccount);
}
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert('request failed' + args.get_message() + '\n' + args.get_stackTrace());
}
});
Tuesday, 27 May 2014
SharePoint 2013: Get UserProfile Properties with REST API
Thanks to
http://www.vrdmn.com/2013/07/sharepoint-2013-get-userprofile.html
1) Get all properties of current user:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties2) Get single property of current user:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties/PictureUrlOR
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=PictureUrl
3) Get Multiple Properties for the current user:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=PictureUrl,AccountName4) Get all properties of Specific User:
For Office 365/SharePoint Online:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='i:0%23.f|membership|vardhaman@siteurl.onmicrosoft.com'
For SharePoint 2013 On-Premise:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v='domain\username'
5) Get Specific UserProfile Property of Specific User:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='LastName')?@v='i:0%23.f|membership|vardhaman@siteurl.onmicrosoft.com'
For SharePoint 2013 On-Premise:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='LastName')?@v='domain\username'
6) Get Multiple UserProfile Properties for Specific User:
http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertiesFor
Sunday, 18 May 2014
My validators are not working
This was working
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup">
</asp:RequiredFieldValidator>
...
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup">
</asp:RequiredFieldValidator>
As soon as I changed it to
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup">
</asp:RequiredFieldValidator>
...
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup">
</asp:RequiredFieldValidator>
...
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup">
</asp:RequiredFieldValidator>
As soon as I changed it to
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup">
</asp:RequiredFieldValidator>
...
<!--
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ForeColor="Red" ErrorMessage="* This field cannot be blank." ControlToValidate="FunctionGroup"></asp:RequiredFieldValidator>
-->
it stopped working. So if you don't want to use validator, instead of commentting out it, delete it.
Thursday, 1 May 2014
SharePoint Search REST API not returning all subsites
This query is not working !!! I have 10 subsites, but it only returns 2 of them.
https://serverURL/_api/search/query?querytext='path:"*********" contentclass:STS_Web'&rowlimit=20
Solution is to add &trimduplicates=false at the end of the query.
https://serverURL/_api/search/query?querytext='path:"*********" contentclass:STS_Web'&rowlimit=20&trimduplicates=false
https://serverURL/_api/search/query?querytext='path:"*********" contentclass:STS_Web'&rowlimit=20
Solution is to add &trimduplicates=false at the end of the query.
https://serverURL/_api/search/query?querytext='path:"*********" contentclass:STS_Web'&rowlimit=20&trimduplicates=false
SharePoint Designer Cache Locations
- %APPDATA%\Microsoft\Web Server Extensions\Cache
- %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
Monday, 7 April 2014
XmlDocument.CreateElement automatically adds xmlns="". How to get ride of it?
Problem:
Solution:
When creating the url element, instead of using
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url xmlns="">
.......................
</url>
</urlset>
Solution:
When creating the url element, instead of using
doc.CreateElement("url");
use doc.CreateElement("url","http://www.sitemaps.org/schemas/sitemap/0.9");
Wednesday, 11 December 2013
SharePoint: Assign Values to the Taxonomy Field
TaxonomyFieldValue TenderNO = item["Tender No"] as TaxonomyFieldValue;
TaxonomyField taxonomyField = newWeb.Lists[i].Fields["Tender No"] as TaxonomyField;
try
{
taxonomyField.DefaultValue = TenderNO.ValidatedString;
}
catch
{
taxonomyField.DefaultValue = String.Empty;
}
taxonomyField.UserCreated = false;
taxonomyField.Update(true);
TaxonomyField taxonomyField = newWeb.Lists[i].Fields["Tender No"] as TaxonomyField;
try
{
taxonomyField.DefaultValue = TenderNO.ValidatedString;
}
catch
{
taxonomyField.DefaultValue = String.Empty;
}
taxonomyField.UserCreated = false;
taxonomyField.Update(true);
Tuesday, 10 December 2013
"Unable to load assembly group. The user assembly group provider was unable to provide any user assemblies for the specified assembly group."
Firstly make sure the the sandboxed service run under a managed account that has permissions on the web application.
Secondly, when building the sandboxed solution, make sure you include the assembly in the package.
Secondly, when building the sandboxed solution, make sure you include the assembly in the package.
Monday, 9 December 2013
Changing CPUExecutionTime is having no effect
I see someone is having this problem, because they miss this statement
$uc.ResourceMeasures.Update()
$uc.ResourceMeasures.Update()
==================================================
# Give our sandboxed solution more resources.
# Worker Process Timeout
$wpe = "900"
# CPU Timeout
$cpu = "900"
# Grab the User Code Service
$uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local
# Output current values
Write-Host ""
Write-Host "Current worker process execution timeout is:" $uc.WorkerProcessExecutionTimeout "seconds" -foreground cyan
Write-Host "Current CPU execution timeout is:" $uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit "seconds" -foreground cyan
Write-Host ""
Write-Host " ***UPDATING***"
Write-Host ""
# Update worker process execution timeout
$uc.WorkerProcessExecutionTimeout = $wpe
# Update CPU execution time
$uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit = $cpu
$uc.ResourceMeasures.Update()
# Update User Code Service
$uc.Update()
# Output new values
Write-Host "New worker process execution timeout is:" $uc.WorkerProcessExecutionTimeout "seconds" -foreground green
Write-Host "New CPU execution timeout is:" $uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit "seconds" -foreground green
Write-Host ""
Write-Host "Now go and restart the sandboxed code service on all servers!!!"
Stop-Service SPUserCodeV4
Start-Service SPUserCodeV4
# Worker Process Timeout
$wpe = "900"
# CPU Timeout
$cpu = "900"
# Grab the User Code Service
$uc=[Microsoft.SharePoint.Administration.SPUserCodeService]::Local
# Output current values
Write-Host ""
Write-Host "Current worker process execution timeout is:" $uc.WorkerProcessExecutionTimeout "seconds" -foreground cyan
Write-Host "Current CPU execution timeout is:" $uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit "seconds" -foreground cyan
Write-Host ""
Write-Host " ***UPDATING***"
Write-Host ""
# Update worker process execution timeout
$uc.WorkerProcessExecutionTimeout = $wpe
# Update CPU execution time
$uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit = $cpu
$uc.ResourceMeasures.Update()
# Update User Code Service
$uc.Update()
# Output new values
Write-Host "New worker process execution timeout is:" $uc.WorkerProcessExecutionTimeout "seconds" -foreground green
Write-Host "New CPU execution timeout is:" $uc.ResourceMeasures["CPUExecutionTime"].AbsoluteLimit "seconds" -foreground green
Write-Host ""
Write-Host "Now go and restart the sandboxed code service on all servers!!!"
Stop-Service SPUserCodeV4
Start-Service SPUserCodeV4
Monday, 2 December 2013
SharePoint 2013: Error Creating Web Application in SharePoint 2013
I recently ran into an issue when creating a new sharepoint 2013 web application. After couple of minutes the dialog box displayed "Internet Explorer cannot display the webpage". I waited another couple of minutes and I found that the web app is actually created in Central Administration. However, when I looked in the Virtual Directory I noticed there was nothing in the folder for my newly created port.
I think it might be a timing out issue and took these steps to solve the problem
- Open IIS Manager and select Application Pools
- On the right hand side of the window click Select Application Pool Defaults...
- Change the following 3 Process Model time settings
- Ping Maximum Response Time
- Shutdown Time Limit
- Startup Time Limit
- I changed all of these from 90 to 900
- Do an iis reset
Wednesday, 20 November 2013
SharePoint 2013: addanapp page only shows 3 buttons [addanapp page is broken]
It is a bug in the designer manager, you experience this bug if you use the designer manager to create a master page.
The image below shows the correct addanapp page. If the bug happens, you will not be able to see the buttons in the red circle.
To fix this, add the following code to your custom.master file.
I added it inside the pageTitle
<h1 id="pageTitle" class="ms-core-pageTitle"> I added it here </h1>
The image below shows the correct addanapp page. If the bug happens, you will not be able to see the buttons in the red circle.
To fix this, add the following code to your custom.master file.
<SharePoint:AjaxDelta id="DeltaPlaceHolderPageTitleInTitleArea" runat="server">
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">
<SharePoint:SPTitleBreadcrumb
runat="server"
RenderCurrentNodeAsLink="true"
SiteMapProvider="SPContentMapProvider"
CentralAdminSiteMapProvider="SPXmlAdminContentMapProvider">
<PATHSEPARATORTEMPLATE>
<SharePoint:ClusteredDirectionalSeparatorArrow runat="server" />
</PATHSEPARATORTEMPLATE>
</SharePoint:SPTitleBreadcrumb>
</asp:ContentPlaceHolder>
</SharePoint:AjaxDelta>
<SharePoint:AjaxDelta BlockElement="true" id="DeltaPlaceHolderPageDescription" CssClass="ms-displayInlineBlock ms-normalWrap" runat="server">
<a href="javascript:;" id="ms-pageDescriptionDiv" style="display:none;">
<span id="ms-pageDescriptionImage"> </span>
</a>
<span class="ms-accessible" id="ms-pageDescription">
<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server" />
</span>
<SharePoint:ScriptBlock runat="server">
_spBodyOnLoadFunctionNames.push("setupPageDescriptionCallout");
</SharePoint:ScriptBlock>
</SharePoint:AjaxDelta>
I added it inside the pageTitle
<h1 id="pageTitle" class="ms-core-pageTitle"> I added it here </h1>
Sunday, 17 November 2013
SharePoint 2013: Where is my dll?
Starting from .NET 4.0, there is a new ‘GAC’ folder “c:\windows\microsoft.net\assembly“.
Monday, 21 October 2013
SharePoint 2010 Workflow Exception: "This task is currently locked by a running workflow and cannot be edited"
If you are experiencing this problem, first thing you need to check
is this great post.
If your workflow is not in Visual Studio, rather it's a SPD
workflow, what you can do is create a Timer Job which runs every couple of minutes and set the workflow version. Here is the Code:
// Feature receiver
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;
using **.Code.TimerJobs;
namespace **.Features.Unlock_Workflow_Tasks
{
[Guid("***")]
public class Unlock_Workflow_Tasks : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
if (webApp == null)
return;
try
{
// make sure the job isn't already registered
foreach (SPJobDefinition job in webApp.JobDefinitions)
{
if (job.Name == JOB_NAME)
job.Delete();
}
}
catch
{
}
// install the job
UnlockWorkflowTasks timerJobDefinition = new UnlockWorkflowTasks(JOB_NAME, webApp);
SPMinuteSchedule schedule = new SPMinuteSchedule();
schedule.Interval = 15;
schedule.BeginSecond = 0;
schedule.EndSecond = 59;
timerJobDefinition .Schedule = schedule;
timerJobDefinition .Update();
}
// Uncomment the method below to handle the event raised before a feature is deactivated.
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
// delete the job
try
{
foreach (SPJobDefinition job in webApp.JobDefinitions)
{
if (job.Name == JOB_NAME)
job.Delete();
}
}
catch
{
}
}
}
}
// The Timer Job
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using **.Code.Utilities;
using Microsoft.SharePoint.Workflow;
namespace **.Code.TimerJobs
{
class UnlockWorkflowTasks : SPJobDefinition
{
public UnlockWorkflowTasks(): base() {}
public UnlockWorkflowTasks(string jobName, SPWebApplication webApplication)
: base(jobName, webApplication, null, SPJobLockType.Job)
{
this.Title = "**";
}
public override void Execute(Guid contentDbId)
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(WebApplication.Sites[0].Url))
using (SPWeb web = site.OpenWeb())
{
UnlockPotentiallyLockedWorkflowTasks(web);
}
});
}
catch (Exception ex)
{
Logger.LogError(ex);
}
}
private void UnlockPotentiallyLockedWorkflowTasks(SPWeb web)
{
try
{
web.AllowUnsafeUpdates = true;
SPListItemCollection tasks = GetPotentiallyLockedTasks(web);
foreach (SPListItem task in tasks)
{
try
{
if ((int)task[SPBuiltInFieldId.WorkflowVersion] != 1)
{
// change it's version to 1.0
SPList parentList = task.ParentList.ParentWeb.Lists[new Guid(task[SPBuiltInFieldId.WorkflowListId].ToString())];
SPListItem parentItem = parentList.Items.GetItemById((int)task[SPBuiltInFieldId.WorkflowItemId]);
SPWorkflow workflow = parentItem.Workflows[new Guid(task[SPBuiltInFieldId.WorkflowInstanceID].ToString())];
if (!workflow.IsLocked)
{
task[SPBuiltInFieldId.WorkflowVersion] = 1;
task.SystemUpdate();
Logger.LogInfo("Unlock task {0} (ID:{1})", task["Title"].ToString(), task["ID"].ToString());
}
}
}
catch (Exception e)
{
Logger.LogError(e);
}
}
}
catch (Exception e)
{
Logger.LogError(e);
}
finally
{
web.AllowUnsafeUpdates = false;
}
}
private SPListItemCollection GetPotentiallyLockedTasks(SPWeb web)
{
var query = new SPQuery();
query.Query = @"
<Where>
<Neq>
<FieldRef Name='Status' />
<Value Type='Choice'>Completed</Value>
</Neq>
</Where>";
//query.ViewAttributes = "Scope=\"Recursive\"";
return web.Lists[WORKFLOW_TASKS_LIST].GetItems(query);
}
}
}
Subscribe to:
Posts (Atom)


