Sitefinity is an online website building tool (application), referred to as a Web Content Management System (CMS). It is a .NET based CMS developed by Progress Software. Its version 14.2 is released by Progress on June 28, 2022
Question:"Telerik.Sitefinity.Security.SecurityDemandFailException" exception while trying to create and upload the document to sitefinity's document library
Description:I am getting following exception while trying to upload document to sitefinity's document library Telerik.Sitefinity.Security.SecurityDemandFailException Telerik.Sitefinity.Libraries.Model.DocumentLibrary, Telerik.Sitefinity.Model was not granted ManageDocument in Document for principals with IDs 00000000-0000-0000-0000-000000000000 [Image] I am using following method and it is throwing exception while I am trying to set its parent library as seen in the above screenshot public static void CreateDocumentNativeAPI(Guid masterDocumentId, string parentDocumentLibraryUrlName, string documentTitle, Stream documentStream, string documentFileName, string documentExtension) { LibrariesManager librariesManager = LibrariesManager.GetManager(); Document document = librariesManager.GetDocuments().Where(d => d.Id == masterDocumentId).FirstOrDefault(); if (document == null) { //The document is created as master. The masterDocumentId is assigned to the master version. document = librariesManager.CreateDocument(masterDocumentId); //Set the parent document library. DocumentLibrary documentLibrary = librariesManager.GetDocumentLibraries().Where(d => d.UrlName.ToLower() == parentDocumentLibraryUrlName).SingleOrDefault(); document.Parent = documentLibrary; //Set the properties of the document. document.Title = documentTitle; document.DateCreated = DateTime.UtcNow; document.PublicationDate = DateTime.UtcNow; document.LastModified = DateTime.UtcNow; document.UrlName = Regex.Replace(documentTitle.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); document.MediaFileUrlName = Regex.Replace(documentFileName.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); //Recompiles and validates the url of the document. librariesManager.RecompileAndValidateUrls(document); //Upload the document file. librariesManager.Upload(document, documentStream, documentExtension); //Save the changes. librariesManager.SaveChanges(); //Publish the DocumentLibraries item. The live version acquires new ID. var bag = new Dictionary<string, string>(); bag.Add("ContentType", typeof(Document).FullName); WorkflowManager.MessageWorkflow(masterDocumentId, typeof(Document), null, "Publish", false, bag); } }
Posted by: Khalid Abbas | Posted on: Jan 25, 2023