A user who created various lists in SharePoint Server 2010 has subsequently been deleted from the site collection. This leaves the user id in the SPList.Author property but results in "User cannot be found" messages in various places that try to instantiate the SPUser object.
Is there any supported way to update the SPList.Author property? I have tried with the server OM, Client OM and lists.asmx web service and have failed with all three.
I've never done it before, but using this guide here, here is what you could try on Powershell:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "your sharepoint site url"
$webName = "your webname"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
$listName = "your listname"
$userLoginName = "your username"
$spList = $spWeb.Lists[$listName]
$spList.Author = $spWeb.AllUsers[$userLoginName]
$spList.Update() // I don't know if this is required.
maybe find a way to remove the user from the sitecollection
I have accepted that it is not possible to update SPList.Author, but my need to do so has also weakened.
The reason I wanted to do this was the encountering of "user cannot be found" errors on the list settings and workflow settings pages. I thought that it may have been originating in the list - because tools like SharePoint manager show "user cannot be found" when I examine the list author property.
It turned out, however, to be coming from workflow templates, not lists, that had been published by the since-removed user.
Related
I have set up a SharePoint Online site and I have created a provider hosted app. One of the features of the app is to create subsites and there are times when a subsite needs to be renamed, including renaming the subsite URL. I can use the CSOM to create the subsite without any problems but when I try to rename the URL I get an access denied error. If I only change the title and description of the subsite there is no problem. If I log into SharePoint Online via the browser (using the same user account!) and I use the UI to rename the URL then it works without any problem. The page in SharePoint I use to rename the URL is https://tenant.sharepoint.com/testproject/_layouts/15/prjsetng.aspx
I have tried this on both a Microsoft 365 Developer subscription (where I am doing most of my development and testing) and the main SharePoint Online site where the solution will eventually be deployed to. I don't know much of the details for the main SPO site, other people set it up and I was provided an account to test renaming the subsite. To be clear, I am able to rename the subsite URL via the UI in both the developer and main SharePoint Online sites.
Is there something I'm doing wrong? Is there a limitation to renaming a subsite URL via code in SharePoint Online? Is there a bug in SharePoint Online that prevents renaming a subsite URL using code?
The exception thrown includes ServerErrorTypeName = "Microsoft.SharePoint.SPException". I can get the correlation id but from what I understand that's of no use in SharePoint Online. The exception Message is literally "Access denied." There is no inner exception.
Here is the code I'm using to rename the subsite:
SharePointContext spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
ClientContext clientContext = new ClientContext(spContext.SPHostUrl)
{
Credentials = new SharePointOnlineCredentials("SPUserName", "SPPassword".ToSecureString())
};
var webUrl = request.OldProjectUrl;
var subweb = clientContext.Site.OpenWeb(webUrl);
clientContext.Load(subweb);
clientContext.ExecuteQuery();
subweb.Title = request.ProjectName;
subweb.Description = request.ProjectName;
subweb.ServerRelativeUrl = "/HardcodedForTesting"; // <-- if I skip this line there is no error
subweb.Update();
clientContext.ExecuteQuery();
I was trying to achieve the same result but encountered the same error.
I was able to solve this by disabling the NoScriptSite setting of the site collection.
Using the PnP.PowerShell module:
Set-PnPSite -NoScriptSite:$false
Also the value you give to the ServerRelativeUrl property must be correctly constructed. I found two allowed format:
/sites/site-collection-path/new-subsite-path
new-subsite-path
Just did a test on my environment, I could rename the subsite URL via CSOM code normally. I use the same code as yours.
For your issue, you'd better create a service request with Microsoft.
if (user.get_isSiteAdmin())
{
document.cookie = "licence=yes";
}
I am using user.get_isSiteAdmin() but its always giving value false I can not give permission to site site collection
Site Collection - Full Control
in AppMenifest.xml file
is there any other way to get site administrator ?
#user11869887,
Just have a test this JSOM function on my SPO environment, it works fine here.
you may need to explicitly initialize the object/properties, or it will always return false as the related property is null.
BR
I want to edit a link on the left side of a SharePoint 2013 Standard site. Clicking on Edit Links and changing the link to a desired site and then saving shows error "This operation has timed out. Please try again." and clicking on Quick launch keeps spinning. I have full access to the site.
What could be the cause ?
did You consider using PowerShell as a workaround solution? If something in SharePoint that is OOB and does not work I always consider PS to fix something :).
For Your case something like this may do the trick (example to delete and update):
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$SPWeb = Get-SPWeb "[URL]";
$QuickLaunch = $SPWeb.Navigation.QuickLaunch;
foreach($item in $QuickLaunch)
{
$item.Title;
if($item.Title -eq '[quickLunchItemTitleToDelete]')
{
$SPWeb.Navigation.GetNodeById($item.Id).Delete();
}
if($item.Title -eq '[quickLunchItemTitleToModify]')
{
$item.Title = "[NewName]";
$item.Update();
}
}
also I saw You have in site settings link to Quick Lunch. But You may turn on a feature in web to get the more advanced 'Navigation' link and maybe from there You will be able to modify the link You need.
Go to Site settings > Under Site collection admin > Site collection
features
Click Activate in-front of SharePoint Server Publishing
Infrastructure
BUT please be aware that turning on this feature will add also other components to Your which may be not desired.
I hope this will be of any help to You :)
If I use the GET statement:
https://graph.microsoft.com/beta/sites/root/sites/ then it correctly returns a list of sub sites under my main SharePoint site. But if I add a new Team Site sub-site to my main site and then run the same command it now returns
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"request-id": "604af4de-b2b5-48cf-802b-1952a7d10b42",
"date": "2017-10-07T16:56:48"
}
}
}
When I delete the new sub-site the GET statement works again. I thought it was an issue with my SharePoint site so I reported it to Office 365 SharePoint support. They get the same error. It happens with Graph v1.0 and beta but is not in the Known Issues list.
I am trying to use this to get the Drive Id of a SharePoint library on a sub-sub site but cannot get past this issue on the problem sub-site. Is there any other way of getting a Drive Id of libraries on the sub-site that Graph at present seems unable to access?
Whilst the issue of Graph not being able to return a list of more than 7 sub-sites is still there, I have found a work around to enable me to get the Drive Ids of the Drives on the sub-sites. By using the /sites: /{sitepath} option (NB the colon) I was able to go directly to the required sub-sites and then get the relevant drive Ids.
I just wanted to follow up and say we have now made some improvements that should hopefully let these kinds of queries work past 7 subsites. So hopefully this issue is now resolved.
Workaround (v1.0 only) : use
https://graph.microsoft.com/v1.0/sites?search=*
as proposed here
We are running a SharePoint 2013 publishing site in 2010 mode. A section of the code which used to work fine in 2010 is not working after I installed the SharePoint 2013 CTP update (Configuration database version:
15.0.4815.1000).
I am trying to add a custom webpart with custom properties. The below code adds the webpart to the correct zone but when SPLimitedWebPartManager.SaveChanges(webpart) executes, it resets the custom property values to default values.
var wpManager = web.GetLimitedWebPartManager(page.ListItem.Url, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)
var dsWebPart = new DocumentSetBridge()
{
Title = "Shared Resource(s)",
ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None,
KnowledgeCenterAssetsLibraryItemId = documentSetUniqueGuid,
ID = KnowledgeCenterSettings.DocumentSetBridgeWebPartId,
ShowManageDocLink = true,
IsUserCommunityDS = true
};
wpManager.AddWebPart(dsWebPart, UserGroupSettings.DOCUMENTSET_WEBPART_ZONE_ID, UserGroupSettings.DOCUMENTSET_WEBPART_ZONE_INDEX);
Any help is much appreciated. Thanks in advance.
Senthil S
UPDATE: Found the issue with permissions. It creates a new page with pre-defined webparts and assigns the user manage rights just for the page. Eventhough, the page is updated with proper permissions, it seems like SP is not recognizing it until sometime later. It could be because of some timing issue. If I add the web part impersonating as an admin everything looks fine.
After adding the WebPart to the SPLimitedWebPartManager you should do the following
wpManager.SaveChanges(dsWebPart);
web.Update();
and/or use SetPersonalizationDirty() like
dsWebPart.SetPersonalizationDirty();