Post SharePoint 2013-将用户添加到UserInformationList

Post SharePoint 2013-将用户添加到UserInformationList,post,sharepoint,sharepoint-2013,user-information-list,Post,Sharepoint,Sharepoint 2013,User Information List,我现在有一个小问题,我还不知道如何解决它。情况是这样的。在SharePoint 2013中,我使用REST-API更新和创建列表项 如果有ppl选择器,则值是UserInformationList中用户的ID。到现在为止,一直都还不错。但现在我的问题来了 这不适用于不在UserInformationList中的用户。当我搜索一个还不存在的用户时,nativc中的SharePoint似乎会发出POST请求。第一个似乎是从另一个列表中获取用户,因为到目前为止ppl选择器中输入了字符串。那具尸体看起来

我现在有一个小问题,我还不知道如何解决它。情况是这样的。在SharePoint 2013中,我使用REST-API更新和创建列表项

如果有ppl选择器,则值是UserInformationList中用户的ID。到现在为止,一直都还不错。但现在我的问题来了

这不适用于不在UserInformationList中的用户。当我搜索一个还不存在的用户时,nativc中的SharePoint似乎会发出POST请求。第一个似乎是从另一个列表中获取用户,因为到目前为止ppl选择器中输入了字符串。那具尸体看起来像这样

   <?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName="Javascript Library">
   <Actions>
      <StaticMethod TypeId="{xxxxxxxxxxxxx}" Name="ClientPeoplePickerSearchUser" Id="5">
         <Parameters>
            <Parameter TypeId="{xxxxxxxxxxxxx}">
               <Property Name="AllowEmailAddresses" Type="Boolean">false</Property>
               <Property Name="AllowMultipleEntities" Type="Boolean">true</Property>
               <Property Name="AllUrlZones" Type="Boolean">false</Property>
               <Property Name="EnabledClaimProviders" Type="String" />
               <Property Name="ForceClaims" Type="Boolean">false</Property>
               <Property Name="MaximumEntitySuggestions" Type="Number">30</Property>
               <Property Name="PrincipalSource" Type="Number">15</Property>
               <Property Name="PrincipalType" Type="Number">1</Property>
               <Property Name="QueryString" Type="String">jack</Property>
               <Property Name="Required" Type="Boolean">false</Property>
               <Property Name="SharePointGroupID" Type="Number">0</Property>
               <Property Name="UrlZone" Type="Number">0</Property>
               <Property Name="UrlZoneSpecified" Type="Boolean">false</Property>
               <Property Name="Web" Type="Null" />
               <Property Name="WebApplicationID" Type="String">{00000000-0000-0000-0000-000000000000}</Property>
            </Parameter>
         </Parameters>
      </StaticMethod>
   </Actions>
   <ObjectPaths />
</Request>
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName="Javascript Library">
   <Actions>
      <ObjectPath Id="3" ObjectPathId="2" />
      <ObjectPath Id="5" ObjectPathId="4" />
      <ObjectPath Id="7" ObjectPathId="6" />
      <ObjectPath Id="9" ObjectPathId="8" />
      <ObjectPath Id="11" ObjectPathId="10" />
      <ExceptionHandlingScopeSimple Id="12">
         <Method Name="ValidateUpdateListItem" Id="14" ObjectPathId="10">
            <Parameters>
               <Parameter Type="Array">
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">Title</Property>
                     <Property Name="FieldValue" Type="String">___test</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">Someone</Property>
                     <Property Name="FieldValue" Type="String" />
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">LookupField</Property>
                     <Property Name="FieldValue" Type="String" />
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">SomeTextField</Property>
                     <Property Name="FieldValue" Type="String" />
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">APerson</Property>
                     <Property Name="FieldValue" Type="String">[{"Key":"i:0#.w|dom\\xxxxxx","Description":"DOM\\xxxxx","DisplayText":"Some, Name","EntityType":"User","ProviderDisplayName":"Active Directory","ProviderName":"AD","IsResolved":true,"EntityData":{"Title":"","MobilePhone":"","SIPAddress":"some.person@mail.com","Department":"XX-XX","Email":"some.person@mail.com"},"MultipleMatches":[],"AutoFillKey":"i:0#.w|dom\\xxxxxxx","AutoFillDisplayText":"Person, Some","AutoFillSubDisplayText":"","AutoFillTitleText":"SomeString","DomainText":"some.domain.net","Resolved":true,"LocalSearchTerm":"some"}]</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">ContentType</Property>
                     <Property Name="FieldValue" Type="String">Element</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">ContentTypeId</Property>
                     <Property Name="FieldValue" Type="String">0x010020785F18D738D74797A0C6B07438E69E</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
               </Parameter>
               <Parameter Type="Boolean">false</Parameter>
               <Parameter Type="Null" />
            </Parameters>
         </Method>
      </ExceptionHandlingScopeSimple>
   </Actions>
   <ObjectPaths>
      <StaticProperty Id="2" TypeId="{xxxxxxxxxxx}" Name="Current" />
      <Property Id="4" ParentId="2" Name="Web" />
      <Property Id="6" ParentId="4" Name="Lists" />
      <Method Id="8" ParentId="6" Name="GetById">
         <Parameters>
            <Parameter Type="String">xxxxxxxxxxx</Parameter>
         </Parameters>
      </Method>
      <Method Id="10" ParentId="8" Name="AddItem">
         <Parameters>
            <Parameter TypeId="{xxxxxxxxxxx}">
               <Property Name="FolderUrl" Type="String">/sites/site/lists/theList</Property>
               <Property Name="LeafName" Type="Null" />
               <Property Name="UnderlyingObjectType" Type="Number">0</Property>
            </Parameter>
         </Parameters>
      </Method>
   </ObjectPaths>
</Request>
然后它返回一个包含用户信息的JSON。当我现在发送表单时,会发出第二个POST请求,基本上包含所有表单信息,看起来有点像这样

   <?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName="Javascript Library">
   <Actions>
      <StaticMethod TypeId="{xxxxxxxxxxxxx}" Name="ClientPeoplePickerSearchUser" Id="5">
         <Parameters>
            <Parameter TypeId="{xxxxxxxxxxxxx}">
               <Property Name="AllowEmailAddresses" Type="Boolean">false</Property>
               <Property Name="AllowMultipleEntities" Type="Boolean">true</Property>
               <Property Name="AllUrlZones" Type="Boolean">false</Property>
               <Property Name="EnabledClaimProviders" Type="String" />
               <Property Name="ForceClaims" Type="Boolean">false</Property>
               <Property Name="MaximumEntitySuggestions" Type="Number">30</Property>
               <Property Name="PrincipalSource" Type="Number">15</Property>
               <Property Name="PrincipalType" Type="Number">1</Property>
               <Property Name="QueryString" Type="String">jack</Property>
               <Property Name="Required" Type="Boolean">false</Property>
               <Property Name="SharePointGroupID" Type="Number">0</Property>
               <Property Name="UrlZone" Type="Number">0</Property>
               <Property Name="UrlZoneSpecified" Type="Boolean">false</Property>
               <Property Name="Web" Type="Null" />
               <Property Name="WebApplicationID" Type="String">{00000000-0000-0000-0000-000000000000}</Property>
            </Parameter>
         </Parameters>
      </StaticMethod>
   </Actions>
   <ObjectPaths />
</Request>
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName="Javascript Library">
   <Actions>
      <ObjectPath Id="3" ObjectPathId="2" />
      <ObjectPath Id="5" ObjectPathId="4" />
      <ObjectPath Id="7" ObjectPathId="6" />
      <ObjectPath Id="9" ObjectPathId="8" />
      <ObjectPath Id="11" ObjectPathId="10" />
      <ExceptionHandlingScopeSimple Id="12">
         <Method Name="ValidateUpdateListItem" Id="14" ObjectPathId="10">
            <Parameters>
               <Parameter Type="Array">
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">Title</Property>
                     <Property Name="FieldValue" Type="String">___test</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">Someone</Property>
                     <Property Name="FieldValue" Type="String" />
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">LookupField</Property>
                     <Property Name="FieldValue" Type="String" />
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">SomeTextField</Property>
                     <Property Name="FieldValue" Type="String" />
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">APerson</Property>
                     <Property Name="FieldValue" Type="String">[{"Key":"i:0#.w|dom\\xxxxxx","Description":"DOM\\xxxxx","DisplayText":"Some, Name","EntityType":"User","ProviderDisplayName":"Active Directory","ProviderName":"AD","IsResolved":true,"EntityData":{"Title":"","MobilePhone":"","SIPAddress":"some.person@mail.com","Department":"XX-XX","Email":"some.person@mail.com"},"MultipleMatches":[],"AutoFillKey":"i:0#.w|dom\\xxxxxxx","AutoFillDisplayText":"Person, Some","AutoFillSubDisplayText":"","AutoFillTitleText":"SomeString","DomainText":"some.domain.net","Resolved":true,"LocalSearchTerm":"some"}]</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">ContentType</Property>
                     <Property Name="FieldValue" Type="String">Element</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
                  <Object TypeId="{xxxxxxxxxxx}">
                     <Property Name="ErrorMessage" Type="Null" />
                     <Property Name="FieldName" Type="String">ContentTypeId</Property>
                     <Property Name="FieldValue" Type="String">0x010020785F18D738D74797A0C6B07438E69E</Property>
                     <Property Name="HasException" Type="Boolean">false</Property>
                  </Object>
               </Parameter>
               <Parameter Type="Boolean">false</Parameter>
               <Parameter Type="Null" />
            </Parameters>
         </Method>
      </ExceptionHandlingScopeSimple>
   </Actions>
   <ObjectPaths>
      <StaticProperty Id="2" TypeId="{xxxxxxxxxxx}" Name="Current" />
      <Property Id="4" ParentId="2" Name="Web" />
      <Property Id="6" ParentId="4" Name="Lists" />
      <Method Id="8" ParentId="6" Name="GetById">
         <Parameters>
            <Parameter Type="String">xxxxxxxxxxx</Parameter>
         </Parameters>
      </Method>
      <Method Id="10" ParentId="8" Name="AddItem">
         <Parameters>
            <Parameter TypeId="{xxxxxxxxxxx}">
               <Property Name="FolderUrl" Type="String">/sites/site/lists/theList</Property>
               <Property Name="LeafName" Type="Null" />
               <Property Name="UnderlyingObjectType" Type="Number">0</Property>
            </Parameter>
         </Parameters>
      </Method>
   </ObjectPaths>
</Request>
第二篇文章似乎也在UserInformationList中创建了用户。所以我的问题是

有没有办法创建UserInformationList中还不存在的用户,并在创建后返回其ID


由于我只是在前端开发SharePoint,所以我对其体系结构不太熟悉。如果你们中有人能在这里帮助我,那就太好了。

如果用户不存在,您可以调用web上的方法来创建用户,并返回其ID。

谢谢。我会努力解决这个问题,回到过去;有一件事仍然是开放的。从人员选取器中,我只返回用户登录名。有了EnsureReuser,我可以创建一个新用户,但还有一个问题是,我没有它的其他信息,如部门、倾斜等。这个API中是否也有一部分可以获取这些信息?我想我不得不模仿第一个POST请求,但要想得到唯一的答案,必须登录。我只是更喜欢使用/web/_api方法,而不是尝试用xml体重建该请求,因为我不确定输入的一半意味着什么。似乎一旦用户添加到ppl选择器,他们就在Active Directory中了。因此,我想现在我必须找到一种方法,使用给定的登录名从Active Directory获取用户信息。如果您需要有关用户的其他信息,可以使用他的个人资料获取这些信息。好的,getProperties有效。我必须首先使用GetMyProperties,因为AccountName不是LoginName,而是格式不同。不幸的是,我无法正确地获取EnsureUser中的JSON数据。我尝试了“logonName”:“I:0.f |成员资格”|user@domain.onmicrosoft.com“现在运气好。尝试使用帐户名和各种组合。我运气不好。你知道这篇文章还应该提交什么吗?