Sharepoint Forum

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds

Adding aspnetdb users to sharepoint user profiles

  Asked By: Dominique Higgins         Date: Oct 12, 2009      Category: Sharepoint      Views: 521
 

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


Do you know someone who can help? Share a link to this thread on twitter, or facebook.

Tagged:              

 

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.


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].