我需要编写一个小软件,它必须在Sharepoint 2010上更新一些列表.
我找到了可以使用url创建的"SPSite",但我无法弄清楚如何指定我想要连接的用户.
用户不是当前的Windows用户,并且该程序未在服务器上执行.
我看到了提供"SPUserToken"的可能性,但在我的方法中我只有用户,域和他的密码,所以如何生成这个用户(我认为这个用户在执行代码的系统上是未知的,但在服务器上已知)
我在哪里可以指定?
谢谢!
我有一个SP Online网站,我存储文档,添加/检索文档没有问题,但在删除流程中,我在检索File
对象时遇到错误.
public static void DeleteDocument()
{
using (ClientContext ctx = ClientContextFactory.Create("https://my-sponline-site.sharepoint.com/sites/documentsite"))
{
Web web = ctx.Web;
ctx.Load(web);
ctx.ExecuteQuery();
string relativeUrl = "/Documents/images.jpg";
File file = web.GetFileByServerRelativeUrl(relativeUrl);
ctx.Load(file);
file.DeleteObject();
ctx.ExecuteQuery();
}
}
Run Code Online (Sandbox Code Playgroud)
该文件的完整文件是" https://my-sponline-site.sharepoint.com/sites/documentsite/Documents/images.jpg "(无法访问2016-12-07)
当我执行此操作时,我得到一个ServerException
:
价值不在预期范围内.
上下文工作正常,因为我能够从库中添加/检索项目,上下文用户是管理员.
我尝试将web url添加到relativeUrl,所以它将是"/documentsite/Documents/images.jpg",但我得到了同样的错误.
我似乎无法弄清楚这一点,有什么建议吗?
谢谢
CamlQuery query = new CamlQuery();
query.ViewXml = @"<View>"
+ "<Query>"
+ "<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>"
+ fileName
+ "</Value>"
+ "</Eq>"
+ "</Where>"
+ "</Query>"
+ "</View>";
ListItemCollection item = list.GetItems(query);
clientContext.Load(item);
clientContext.ExecuteQuery();
Run Code Online (Sandbox Code Playgroud)
此查询给了我错误一个或多个字段类型未正确安装.转到列表设置页面以删除这些字段.
如果我用<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>
而不是Name
,那就没关系.
它出什么问题了 ?列表中有名称.
提前致谢 !!!
我是SharePoint新手,希望使用C#ClientContext类和CAML Query删除SharePoint列表中的所有行.
我怎样才能有效地实现它?
sharepoint sharepoint-2010 sharepoint-list c#-4.0 sharepoint-clientobject
我一直在学习客户端对象模型,并且遇到了这个方法executeQueryAsync
.我发现有很多方法可以调用这种方法.我发现的一些是这些:
var context = new SP.ClientContext.get_current();
// Option 1
context.executeQueryAsync(
function(sender, args){ },
function(sender, args){ }
);
// Option 2
context.executeQueryAsync(
Function.createDelegate(this, _onSucceed),
Function.createDelegate(this, _onFail)
);
// Option 3
context.executeQueryAsync(
Function.createDelegate(this, this._onSucceed),
Function.createDelegate(this, this._onFail)
);
// Option 4
context.executeQueryAsync(_onSucceed, _onFail);
Run Code Online (Sandbox Code Playgroud)
哪种方式最优/最优?该声明还有什么作用Function.createDelegate
?这个功能的文档似乎对我来说非常神秘.
javascript sharepoint sharepoint-clientobject sharepoint-2013
我有一个场景,我必须将SharePoint 2010列表中的所有数据(name ="VersionTestList")移动到SQL Server数据库.由于在列表中启用了版本控制,我还想移动以前的版本细节.无论如何,我能够移动最新的项目,但不幸的是我无法获得以前的版本数据.我已经尝试使用客户端对象模型并且能够获取版本,但无法获取相应版本的ListItem.请在下面找到我迄今为止尝试过的代码,并帮我解决这个问题.
另外,我正在使用ListItem的版本:
string path = web.ServerRelativeUrl + "/Lists/VersionTestTable/1_.000";
File file = web.GetFileByServerRelativeUrl(path);
clientContext.Load(file, item=>item.ListItemAllFields);
FileVersionCollection versions = file.Versions;
clientContext.Load(versions);
oldVersions = clientContext.LoadQuery(versions.Where(v => v != null));
clientContext.ExecuteQuery();
Run Code Online (Sandbox Code Playgroud)
我的整个代码是这样的:
class Program
{
static void Main(string[] args)
{
GetVersionsUsingCOM();
}
public static void GetVersionsUsingCOM()
{
File file;
FileVersionCollection versions;
IEnumerable<Microsoft.SharePoint.Client.FileVersion> oldVersions;
ClientContext clientContext = new ClientContex("http://server:1200/test/Poc");
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();
string path = web.ServerRelativeUrl + "/Lists/VersionTestTable/1_.000";
file = web.GetFileByServerRelativeUrl(path);
clientContext.Load(file, item=>item.ListItemAllFields);
//clientContext.ExecuteQuery();
versions = file.Versions;
clientContext.Load(versions);
oldVersions …
Run Code Online (Sandbox Code Playgroud) 只是一个简单的问题,是否可以使用SharePoint 2010中的客户端对象模型创建文档库?
我知道你可以创建列表等.我是否正确地说文档库只是一种'特殊'类型的列表?
如何指定我创建的列表将是文档库?
任何帮助将不胜感激
谢谢
出于某种原因,我的SharePoint模式对话框无法正常工作.我得到的错误是这样的:
SP.UI.$create_DialogOptions is not a function
Object doesn't support this property or method
这是我的代码:
var options = SP.UI.$create_DialogOptions();
options.width = 525;
options.height = 300;
options.url = '/_layouts/mywork/richtexteditor.aspx';
options.dialogReturnValueCallback = Function.createDelegate(null, function (result, value)
{
alert(result + value);
});
SP.UI.ModalDialog.showModalDialog(options);
Run Code Online (Sandbox Code Playgroud)
有趣的是,当我在Firebug中检查SP.UI时,我没有看到所有的方法和属性.
注意:我使用的是标准Webpart(非可视化),而不是应用程序页面.
所以我试图创建一个主要用于更改SharePoint中字段值的方法.
这就是我到目前为止......
static String fieldName1 = "Title";
static String fieldName2 = "Keywords";
static String title = "A Beautiful Sunset";
static String keywords1 = "test1";
static String keywords2 = "test2";
static String keywords3 = "test3";
static NetworkCredential credentials = new NetworkCredential(username, password, domain);
static ClientContext clientContext = new ClientContext(URL);
static Web site = clientContext.Web;
static List list = site.Lists.GetByTitle(listName);
static FileCreationInformation newFile = new FileCreationInformation();
private static void updateFields()
{
clientContext.Load(list);
FieldCollection fields = list.Fields;
clientContext.Load(fields);
clientContext.Load(list.RootFolder);
ListItemCollection listItems = list.GetItems(CamlQuery.CreateAllItemsQuery()); …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个小型.NET概念验证控制台应用程序,它在SharePoint文档库上执行一系列操作.我注意到以下方法需要一个"编码"登录名 - 即登录名,包括提供者信息,例如i:0#.w|DOMAIN\user
.
context.Web.EnsureUser(encodedLoginName);
context.Web.SiteUsers.GetByLoginName(encodedLoginName);
Run Code Online (Sandbox Code Playgroud)
如何DOMAIN\user
在SharePoint客户端对象模型中可靠地将用户名转换为此编码格式?
.net c# sharepoint-api sharepoint-clientobject sharepoint-2013