I am developing a web service that will syncronize user information between two systems. I have a function defined like this :
private void SaveUser(UserSyncRequest request) { Dynamicweb.Modules.UserManagement.User.set_Current(PagePermissionLevels.Backend, Dynamicweb.Modules.UserManagement.User.GetUserByID(4)); string userSQL = string.Format("SELECT * FROM AccessUser WHERE AccessUserEmail = '{0}' AND AccessUserType = 15", request.Contact.Email.Trim()); Dynamicweb.Modules.UserManagement.User userToSave = Dynamicweb.Modules.UserManagement.User.GetUserBySql(userSQL); if (userToSave == null) { userToSave = new Dynamicweb.Modules.UserManagement.User(); userToSave.Type = UserType.ExtranetUser; } userToSave.UserName = request.LoginName; userToSave.Password = request.Password; userToSave.Name = string.Format("{0} {1}", request.Contact.Name, request.Contact.Surnames); userToSave.Email = request.Contact.Email; userToSave.Phone = request.Contact.MainPhoneNumber; userToSave.Address = request.Address.AddressLine1; userToSave.Address2 = request.Address.AddressLine2; userToSave.Zip = request.Address.PostCode; userToSave.City = request.Address.City; userToSave.Country = request.Address.Country; userToSave.Save(); }
I'm getting this error though, and can't really see what is required to get rid of it.
Object reference not set to an instance of an object.
at Dynamicweb.Modules.UserManagement.User.set_Current(PagePermissionLevels level, User value)
at CRMIntegrationService.IntegrationService.SaveUser(UserSyncRequest request) in C:\Websites\DeltaQCRM\Application\Public\DeltaQCRM\IntegrationService.asmx.cs:line 76
at CRMIntegrationService.IntegrationService.SyncIndividualUserDetails() in C:\Websites\DeltaQCRM\Application\Public\DeltaQCRM\IntegrationService.asmx.cs:line 39
Can anyone tell me what I am missing? Thanks.
Marco