简体   繁体   English

使用CSOM在SharePoint 2013中创建托管属性c#

[英]Creating Managed Properties in the SharePoint 2013 Using CSOM c#

I'm using SPMeta2 CSOM code to create and populate lists,contentTypes and columns to my onpremm sharepoint site, but i cannot find a way to create Managed Properties. 我正在使用SPMeta2 CSOM代码创建并填充onpremm共享点站点的列表,contentTypes和列,但是我找不到创建托管属性的方法。

Is there any way to do it, i have googled and just found Powershell and SSOM code that can do it. 有没有办法做到这一点,我已经谷歌搜索,只是发现可以做到这一点的Powershell和SSOM代码。

Add-Type -Path "C:\\Program Files\\Common Files\\Microsoft Shared\\Web Server Extensions\\15\\ISAPI\\Microsoft.SharePoint.Client.dll" 添加类型-路径“ C:\\ Program Files \\ Common Files \\ Microsoft Shared \\ Web服务器扩展\\ 15 \\ ISAPI \\ Microsoft.SharePoint.Client.dll”

Add-Type -Path "C:\\Program Files\\Common Files\\Microsoft Shared\\Web Server Extensions\\15\\ISAPI\\Microsoft.SharePoint.Client.Runtime.dll" 添加类型的路径“ C:\\ Program Files \\ Common Files \\ Microsoft Shared \\ Web服务器扩展\\ 15 \\ ISAPI \\ Microsoft.SharePoint.Client.Runtime.dll”

Add-Type -Path "C:\\Program Files\\Common Files\\Microsoft Shared\\Web Server Extensions\\15\\ISAPI\\Microsoft.SharePoint.Client.Search.dll" 添加类型路径“ C:\\ Program Files \\ Common Files \\ Microsoft Shared \\ Web服务器扩展\\ 15 \\ ISAPI \\ Microsoft.SharePoint.Client.Search.dll”

     try
        {

         var User = "userName";
         var Password = "password";
         var SiteURL = "http://siteUrl/";
         var domainName = "domain name";
        var xDocument = XDocument.Load(@"C:\MyFile11.xml");        
        string xml = xDocument.ToString();


        var context = new Microsoft.SharePoint.Client.ClientContext(SiteURL);
        context.Credentials =   new NetworkCredential(User, GetSecurePassword(Password),domainName);


        var searchConfigurationPortability = new Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability(context);
        var Search = new Microsoft.SharePoint.Client.Search.Portability.SearchConfigurationPortability(context);
        var Owner = new Microsoft.SharePoint.Client.Search.Administration.SearchObjectOwner(context, SearchObjectLevel.Ssa);

        //Export search conf schema
        var SearchConfig = Search.ExportSearchConfiguration(Owner);
        context.ExecuteQuery();

        XmlDocument xdoc = new XmlDocument();
        xdoc.LoadXml(SearchConfig.Value);
        xdoc.Save("myfilenameSSA.xml");

        // import search conf schema
        Search.ImportSearchConfiguration(Owner, xml);
        context.ExecuteQuery();

        }           
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM