RE: Sharepoint Profile Update

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I actually found a site with a clear answer on how to get a web service into
a class library, so was able to switch over to using the web service and all
seems to be working now.

Thanks for your help.

"Gerhard" wrote:

Thanks.

I'd love to use the Web Service, but see no way to add a reference to it
into the Class I am building. I'm working in Visual Studio 2008, and Add Web
Reference is not an option for a Class. Is there a way to do this?



""Steven Cheng"" wrote:

Hi Gerhard,

As for the ServerContext.GetContext, you can use reflector to inspect its
code logic. Here is the disassembled code of it(which accept a SpSite as
input parameter):

=============
public static ServerContext GetContext(SPSite site)
{
if (site != null)
{
return GetContext(site.WebApplication);
}
return null;
}

==========

As you can see, you need to first ensure the SpSite and
SPSite.WebApplication is not null in your program.

Also, I think the problem is also environment specific as my test
environment is a single standalone farm. Maybe your server which run the
code is not the server with central admin or the shared service provider.
If possible, you can also try it on some other MOSS server to see whether
the code works.

In addition, if the objectModel really cannot meet your scenario, onething
left is the webservice interface(which does not require you to call it on
the server):

#Get the User Profile through MOSS Web Services
http://blogs.msdn.com/infopath/archive/2007/03/07/get-the-user-profile-throu
gh-moss-web-services.aspx

you can get the asmx reference via the following url on each site:

http://[servername]:[port]/_vti_bin/UserProfileService.asmx

the webservice contains method for querying userprofile(via account name or
guid) and update a certain profile property via accountName.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.



--------------------
From: =?Utf-8?B?R2VyaGFyZA==?= <Gerhard@xxxxxxxxxxxxxxxx>
References: <D86C7CD7-FB4C-45F7-B312-BE24DCABCE0A@xxxxxxxxxxxxx>
<VKJ03PE1JHA.4372@xxxxxxxxxxxxxxxxxxxxxx>
<C01DFE21-6BC8-4836-98F4-D448DCE6D87A@xxxxxxxxxxxxx>
<IrCmrHU1JHA.2060@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: Sharepoint Profile Update
Date: Fri, 15 May 2009 09:59:01 -0700


Thanks for your reply.

That looks like the same code you originally sent me that errors out (I am
working on the same machine as Sharepoint server).

Is there any other way to establish an "upmanager" as below that isn't so
dependent upon the location where the code is run?

Thanks again.

""Steven Cheng"" wrote:

Thanks for your reply Gerhard,

As for the "ServerContext", you can use the static "GetContext" method to
acquire a context from a given SpSite or SPWebApplication. As you can
see
in my test code:
=================
static void AccessUserProfile()
{

SPSite site = new SPSite("http://stcheng-2k3-vpc:8888";);

UserProfileManager upmanager = new
UserProfileManager(ServerContext.GetContext(site));
UserProfile p1 =
upmanager.GetUserProfile(@"STCHENG-2K3-VPC\Administrator");
........

================

Sure, you do not need to run the code in a web application(or in a SPS
page). You can encapsulate the code into a dll assembly. However, it is
necessary that you run the code on the sharepoint server machine so that
the SPSite class can correctly found the site instance.

Sincerely,
.



Relevant Pages

  • RE: Sharepoint Profile Update
    ... I'd love to use the Web Service, but see no way to add a reference to it ... Reference is not an option for a Class. ... Here is the disassembled code of it(which accept a SpSite as ... code is not the server with central admin or the shared service provider. ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Web Service - System.UnauthorizedAccessException
    ... To complicate things a little this web service is running on a server with Sharepoint Portal 2003 Server and Windows Sharepoint Services installed. ... supplied UNC path to a supplied Sharepoint website. ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Web Service Implementation Security Question
    ... Server was unable to process ... CompilerParameters parameters, Assembly assembly, Hashtable assemblies) at ... > As for the security problems regarding on using TypedDAtaset in asp.net ... Web Service Implementation Security Question ...
    (microsoft.public.inetserver.iis.security)
  • Re: Permission Errors
    ... >a domain account so that it can be validated on the win2k server machine. ... However I have discovered that I can deploy the web service to the W2K ... domain server and there it runs with no problems, ... for me to decide that the new XP dev machine is up and usable. ...
    (microsoft.public.dotnet.general)
  • Re: Permission Errors
    ... I built the TempConvert3 sample web service on the XP work ... Next I looked at the 2003 server and saw that the local path was ... XP work station. ... >>local workstation, not the server. ...
    (microsoft.public.dotnet.general)