RE: Sharepoint Profile Update
- From: Gerhard <Gerhard@xxxxxxxxxxxxxxxx>
- Date: Mon, 18 May 2009 12:45:03 -0700
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,see
As for the "ServerContext", you can use the static "GetContext" method to
acquire a context from a given SpSite or SPWebApplication. As you can
in my test code:upmanager.GetUserProfile(@"STCHENG-2K3-VPC\Administrator");
=================
static void AccessUserProfile()
{
SPSite site = new SPSite("http://stcheng-2k3-vpc:8888");
UserProfileManager upmanager = new
UserProfileManager(ServerContext.GetContext(site));
UserProfile p1 =
........
================
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,
- Follow-Ups:
- RE: Sharepoint Profile Update
- From: "Steven Cheng"
- RE: Sharepoint Profile Update
- References:
- Sharepoint Profile Update
- From: Gerhard
- RE: Sharepoint Profile Update
- From: "Steven Cheng"
- RE: Sharepoint Profile Update
- From: Gerhard
- RE: Sharepoint Profile Update
- From: "Steven Cheng"
- RE: Sharepoint Profile Update
- From: Gerhard
- RE: Sharepoint Profile Update
- From: "Steven Cheng"
- RE: Sharepoint Profile Update
- From: Gerhard
- Sharepoint Profile Update
- Prev by Date: SharePoint lists, Audience use, Active Directory and Custom Code
- Next by Date: RE: Sharepoint Profile Update
- Previous by thread: RE: Sharepoint Profile Update
- Next by thread: RE: Sharepoint Profile Update
- Index(es):
Relevant Pages
|