Monday, 6 January 2014

Getting Current User & Check User in Specific Group ?

InfoPath-->Data Connection-->New-->Received Data-->SOAP Service-->
   web service url:-
   I.GetUserProfileByName:http://servername/sites/sitename/_vti_bin/UserProfileService.asmx
   II.GetUserCollectionFromGroup:http://servername/sites/sitename/_vti_bin/UserGroup.asmx
   Note:set exact group name in both place
   Change the GetUserCollectionFromGroup data connection using the following way & code:-
   Publish-->Export Source Files on your own specified location
   i.Close the Original infopath form
   ii.Open with VS2010 the GetUserCollectionFromGroup1.xsd file or maximum size of GetUserCollectionFromGroup(x).xsd file
   iii.use the XML Editor to view and edit the underlying XML schema file
   iv.

   At the top of the file, locate the following line:

<s:import namespace="http://www.w3.org/2001/XMLSchema"></s:import>

Right underneath that line, insert the following code:

<!-- Beginning of insert -->
<s:complexType name="GetUserCollectionFromGroupType">
 <s:sequence>
  <s:element minOccurs="0" maxOccurs="1" name="Users">
   <s:complexType>
    <s:sequence>
     <s:element maxOccurs="unbounded" name="User" >
      <s:complexType>
       <s:attribute name="Notes" type="s:string"></s:attribute>
       <s:attribute name="Name" type="s:string"></s:attribute>
       <s:attribute name="IsSiteAdmin" type="s:string"></s:attribute>
       <s:attribute name="Sid" type="s:string"></s:attribute>
       <s:attribute name="ID" type="s:string"></s:attribute>
       <s:attribute name="LoginName" type="s:string"></s:attribute>
       <s:attribute name="Email" type="s:string"></s:attribute>
       <s:attribute name="IsDomainGroup" type="s:string"></s:attribute>
      </s:complexType>
     </s:element>
    </s:sequence>
    </s:complexType>
  </s:element>
 </s:sequence>
</s:complexType>
<!-- End of Insert -->

[EDIT:  Please make sure there is no space in the above </s:complexType>]

Now find the following code:

<s:element name="GetUserCollectionFromGroup">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>
    </s:sequence>
  </s:complexType>
</s:element>

Comment out that code by placing a <!-- before the beginning and an --> after the end.  Result should look like this:

<!--<s:element name="GetUserCollectionFromGroup">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="groupName" type="s:string"></s:element>
    </s:sequence>
  </s:complexType>
</s:element>-->

Right underneath that commented out code, insert the following code:

<!-- Beginning of Insert -->
<s:element name="GetUserCollectionFromGroup" type="tns:GetUserCollectionFromGroupType" />
<!-- End of Insert -->

Save and close the file

v.Go back to the folder where you saved those Source Files to.  Find the file "manifest.xsf" and
RIGHT-click the file and choose "Design".
This will open your InfoPath file back up.  Click SAVE AS and save as a new .xsn file.

Note:
Everything you have done after that if you are getting the following errors:-

************
Error 1:
An error occurred while trying to connect to a Web service.

An entry has been added to the Windows event log of the server.
Log ID:5566
---------------
Error 2:
The following query failed: GetUserCollectionFromGroup (User: SHAREPOINT3\spuser1, Form Name: SOR, IP: , Connection Target: , Request: http://sharepoint/_layouts/FormServer.aspx?XmlLocation=/sites/agc/SOR/131224063651.xml&ClientInstalled=false&Source=http://sharepoint/sites/agc/SOR/Forms/AllItems.aspx&DefaultItemOpen=1, Form ID: urn:schemas-microsoft-com:office:infopath:SOR:-myXSD-2013-12-03T05-15-35 Type: DataAdapterException, Exception Message: The remote server returned an error: (401) Unauthorized.
The remote server returned an error: (401) Unauthorized.)
****************
Solution:
You should check & do the following steps:-

1.IIS-->Authentication-->ASP.NET Impersonation Enabled. ( try with disabled also, if it is already enabled)
2.RUN-->regedit-->HKEY_LOCAL_MACHINE-->SYSTEM-->CurrentControlSet-->Control-->
        Lsa(Right click)-->
  Create new DWORD(32 bit) value or QWORD(64 bit) value with the name as a "DisableLoopbackCheck"
  Then edit it give value as a "1".
3.Check Who can view the membership of the group?   
  "Everyone" 
Ref:

1 comment:

  1. Hi guys,
    Thank you so much for this wonderful article! Here we all can learn a lot of useful things and this is not only my opinion!
    Even BLNCK corp. and http://www.tzunami.com confirmed it!

    ReplyDelete