Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Adding aspnetdb users to sharepoint user profiles

  Asked By: Dominique    Date: Oct 12    Category: Sharepoint    Views: 2281

i tried creating aspnetb users in moss 2007 user profiles ,but i received a
error
"The trust relationship between the primary domain and the trusted domain
failed".

The code used was
string username =
WebConfigurationManager.AppSettings["ImpersonationUsername"].ToString();
string password =
WebConfigurationManager.AppSettings["ImpersonationPassword"].ToString();
string domain =
WebConfigurationManager.AppSettings["ImpersonationDomain"].ToString();
WindowsImpersonationContext wic = CreateIdentity(username, domain,
password).Impersonate();
string url = SPControl.GetContextWeb(Context).Url;
SPSite _SPSite = new SPSite(url);
SPWeb spWeb = _SPSite.OpenWeb();
string currentUser = spWeb.CurrentUser.Name;
ServerContext serverContext = ServerContext.GetContext(_SPSite);
UserProfileManager userProfileManager = new UserProfileManager(serverContext);
UserProfile userProfile =
userProfileManager.CreateUserProfile(txtUserName.Text.Trim());
userProfile["Segment"].Value = txtSegment.Text.Trim();
userProfile["WorkEmail"].Value = txtEmail.Text.Trim();
userProfile["PreferredName"].Value = txtPreferredUserName.Text.Trim();
userProfile.Commit();
wic.Undo();

This is the code which is available on msdn .I was trying to add user through a
webpart

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Adding aspnetdb users to sharepoint user profiles Or get search suggestion and latest updates.




Tagged: