SharePoint userprofileservice ModifyUserPropertyByAccountName - InfoPath Dev
in

InfoPath Dev

SharePoint userprofileservice ModifyUserPropertyByAccountName

Last post 02-13-2009 01:37 AM by Classgenerator. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-10-2009 04:12 AM

    SharePoint userprofileservice ModifyUserPropertyByAccountName

    Hi Experts,

    can not find a Documentation (just specification) on how to pass the ArrayOfPropertyData-parameter for the

    WebMethod ModifyUserPropertyByAccountName of SharePoint-WebService _vti_bin/userprofileservice.asmx 

    when adding a Data Connection to my browser-enabled Form. I want to update a specific property in the UserProfileStore.

    In the Data Connection Wizard the parameter is:

    Parameter Typ Element
    s0:newData ArrayOfPropertyData (complex type) /my:Group/my:Field

    In the parameter option section i can choose a field or group. BUT: how do i tell infopath which property to update with the selected value ???

    Do i have to insert the complete xml of the complex type regarding the property and the value i want to update?

    like this?

    <PropertyData>
              <IsPrivacyChanged>false</IsPrivacyChanged>
              <IsValueChanged>true</IsValueChanged>
              <Name>UserProfilePropertyName</Name>
              <Privacy></Privacy>
              <Values>
                <ValueData xsi:nil="true" ></my:Group/my:Field></ValueData>
                <ValueData xsi:nil="true" />
              </Values>
    </PropertyData>

    Should be different? Right?

    Any help out there....

    Thanks Ronny

  • 02-13-2009 01:37 AM In reply to

    Re: SharePoint userprofileservice ModifyUserPropertyByAccountName

    Hi,

    i couldn't wait no more, so i developed my own Web-Service which updates against the Object-Model of the UserProfileStore.

    This works great. Feel free to use this...

    • Create a WebService-Project
    • Add a Reference to Microsoft.Office.Server and to Microsoft.SharePoint and Microsoft.SharePoint.Security;
    • Add the using you need: using Microsoft.Office.Server;using Microsoft.Office.Server.UserProfiles;using Microsoft.SharePoint;using Microsoft.SharePoint.Security;using Microsoft.SharePoint.Administration;using System.Security.Permissions;
    • Give your MOSS-Contributer the permissions to manage user profiles (http://moss:40000/ssp/admin/_layouts/ManageServicePermissions.aspx)
    • Add this attribute to the class: [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
    • Declare private UserProfileManager UPM = null;
    • May you want to log... : Declare internal string LogPath = SPDiagnosticsService.Local.LogLocation + "/UPS.utilities.log"; internal StreamWriter logger = null;
    • Add a logging method, e.g.: private void Write(string message) { SPSecurity.RunWithElevatedPrivileges(delegate() { logger = new StreamWriter(LogPath, true); logger.WriteLine(System.DateTime.Now.ToString() + " - " + message); logger.Flush(); logger.Close(); logger.Dispose(); }); }
    • In your webmethod create a instance of UserProfileManager : using (SPSite site = new SPSite(http://intranet)) {ServerContext context = ServerContext.GetContext(site);UPM = new UserProfileManager(context);}
    • Determine the UserProfile of a user: UserProfile profile = UPM.GetUserProfile(UserName); UserName should be a parameter of the webmethod (domain\user).

    • To update a property set the value: profile["Porpertyname"].Value = newValue.ToString();

    • Commit the change: profile.Commit();

    • Sign the assembly and install it to the GAC.

    • Publish the WebService e.g. as a virtual directory under your Moss-Site

    • In the InfoPath-Form add Fields you need to set as the WebService-Parameter. Set the values e.g. in the Formoptions (Open/Rules) or somewhere else where it meets your requirements. 

    • Create a DataConnection (send data; WebService) and choose your WebService.

    • Choose the Fields to set as the parameter.

    • Call the WebService from e.g. a rule of a command-button

    This works fine in my Kerberos-Environment

    Good luck

    Ronny

     

     

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.