using (SPSite startSite = new SPSite("url"))
{
SPFarm farm = startSite.WebApplication.Farm;
SPWebService service = farm.Services.GetValue("");
foreach (SPWebApplication webApplication in service.WebApplications)
{
foreach (SPSite site in webApplication.Sites)
{
Console.WriteLine(string.Format("{0} - {1}", site.Url, site.ContentDatabase.Name));
}
}
}
Hi
ReplyDeleteCan you tell me how to programatically get user profile DB from a webpart
can you please be more clear with your question..
ReplyDeletewhat actually your requirement...
ReplyDeleteIf i am not wrong you need the database name from for user profile right?? if so ... then create a webpart project in visual studio and put a button on that and write the above code in code behind, put a text box or list also and instead of "Console.WriteLine(string.Format("{0} - {1}", site.Url, site.ContentDatabase.Name));" just put textbox.text=textbox.text+site.contentdatabase.name.tostring() or listbox.items.add(site.contentdatabase.name);
ReplyDeletehope this fulfill your requirement...
Hi
ReplyDeleteMy problem is that i am trying to update the profile of a user through a web part and for that i want to read the database name so that i can update the value using Client object model ..thank you the suggestion
i dont know nw whether you can update the database directly using client object model... better you use sharepoint apis to update the user profile
ReplyDeletemean while i research and check you go through this
http://msdn.microsoft.com/en-us/library/ms518939.aspx
you know to make visual web parts in visual studio right if not let me know...
No Javascript API is avaiable to update the user profiles. You can however, use UserProfileService.asmx web service to modify user profiles
ReplyDeletecheck this
ReplyDeleteusing System;
using System.Collections.Generic;
using System.Text;
namespace UserProfileWebServiceApp
{
class Program
{
public static localhost.UserProfileService myService =
new localhost.UserProfileService();
UserProfileWebService.localhost.PropertyData[] newdata =
new UserProfileWebService.localhost.PropertyData[1];
newdata[0] =
new UserProfileWebService.localhost.PropertyData();
newdata[0].Name = "HomePhone";
newdata[0].Values = new ValueData[1];
newdata[0].Values[0] = new ValueData();
newdata[0].Values[0].Value = "nnnnnnnnnnn";
newdata[0].IsValueChanged = true;
myService.ModifyUserPropertyByAccountName("domainname\\username",
newdata);
}
}
http://msdn.microsoft.com/en-us/library/ms544240.aspx
http://msdn.microsoft.com/en-us/library/websvcuserprofileservice.aspx
ReplyDeleteThank you very much the MSDN link is the one i am looking for ,,i will construct the visual web part ..Thanks a alot..
ReplyDeletehttp://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/802dbc0f-544e-4bfe-80a1-8bd5af5c8fea/
ReplyDeleteHi
ReplyDeleteI appreciate your efffort.It is nice idea to create a informative sie. It happened to see your website page as well as several written piece. Is exceedingly good type publishing.
Ecommerce developer
Hi,
ReplyDeleteCan i get the list of user profiles which matches 2 different property values, e.g. If user is "active" and user manager is "xyz". i dont want to loop here. i need at a time like quering the DB or list.
Please help
Better ask your question here
Delete@
http://social.technet.microsoft.com/Forums/en-us/sharepoint2010general/threads
also
meanwhile i will also try to find out the way.