public dtoBaseProfile GetCurrentProfileData(Int32 idProfile, Int32 idProfileType, AuthenticationProviderType type, dtoBaseProfile oldProfile) { dtoBaseProfile profile = new dtoBaseProfile(); Person person = CurrentManager.GetPerson(idProfile); if (person != null) { Language language = CurrentManager.GetLanguage(person.LanguageID); switch (idProfileType) { case (int)UserTypeStandard.Company: profile = new dtoCompany(CurrentManager.Get <CompanyUser>(idProfile)); break; case (int)UserTypeStandard.Employee: profile = new dtoEmployee(CurrentManager.Get <Employee>(idProfile)); break; default: profile = oldProfile; break; } profile.IdProfileType = idProfileType; profile.AuthenticationProvider = type; profile.IdLanguage = language.Id; profile.LanguageName = language.Name; } return(profile); }
private Boolean AddAuthentication(Person person, dtoBaseProfile profile, dtoImportSettings settings, ProfileAttributesRow row, AuthenticationProvider provider) { Boolean result = false; if (provider.ProviderType == AuthenticationProviderType.Internal) { InternalLoginInfo info = InternalService.GenerateUserInfo(person, profile.Login, profile.Password, (InternalAuthenticationProvider)provider, false); result = (info != null); } else { dtoExternalCredentials credentials = new dtoExternalCredentials(); if (lm.Comol.Core.DomainModel.PermissionHelper.CheckPermissionSoft((int)provider.IdentifierFields, (int)IdentifierField.longField)) { long identifierLong = 0; long.TryParse(row.GetCellValue(ProfileAttributeType.externalId), out identifierLong); credentials.IdentifierLong = identifierLong; } if (lm.Comol.Core.DomainModel.PermissionHelper.CheckPermissionSoft((int)provider.IdentifierFields, (int)IdentifierField.stringField)) { credentials.IdentifierString = row.GetCellValue(ProfileAttributeType.externalId); } if (UrlService.VerifyDuplicateExternalLoginInfo(person, provider, credentials) == ProfilerError.none) { ExternalLoginInfo externaLogin = UrlService.AddExternalProfile(person, provider, credentials); result = (externaLogin != null); } } return(result); }
private void MoveFromStepProfileTypeSelector() { Int32 tokenIdType = View.TokenIdProfileType; Int32 idOrganization = View.TokenIdOrganization; if (idOrganization == 0) { idOrganization = View.SelectedOrganizationId; } MacUrlAuthenticationProvider provider = GetProvider(); dtoBaseProfile profile = new dtoBaseProfile(); if (tokenIdType > 0) { profile.IdProfileType = tokenIdType; } else if (provider != null) { profile.IdProfileType = View.SelectedProfileTypeId; } if (profile.IdProfileType > 0) { profile = Helper.GetProfileData(provider, provider.GetProfileAttributes(), View.TokenAttributes, idOrganization, profile.IdProfileType); View.GotoStepProfileInfo(profile); View.DisableInput(provider.GetNotEditableAttributes(View.TokenAttributes)); } }
public void CreateProfile(dtoBaseProfile profile, Int32 idProfileType, String ProfileName, Int32 idOrganization) { MacUrlAuthenticationProvider provider = GetProvider(); List <ProfilerError> errors = UrlService.VerifyProfileInfo(profile, View.idProvider, View.ExternalCredentials); if (errors.Count == 0) { ProfileSubscriptionMessage message = View.CreateProfile(profile, idProfileType, ProfileName, idOrganization, AuthenticationProviderType.UrlMacProvider, View.idProvider); Int32 idPerson = View.IdProfile; if (idPerson > 0) { PolicyService.SaveUserSelection(CurrentManager.GetPerson(idPerson), View.GetPolicyInfo); } if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon && idPerson > 0) { Person person = CurrentManager.GetPerson(idPerson); UrlService.UpdateCatalogueAssocation(idPerson, provider, View.TokenAttributes); View.LogonUser(person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(idPerson)); } else { if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon) { message = ProfileSubscriptionMessage.Created; } View.LoadRegistrationMessage(message); } } else { if (errors.Contains(ProfilerError.loginduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.LoginDuplicated); } else if (errors.Contains(ProfilerError.mailDuplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.MailDuplicated); } else if (errors.Contains(ProfilerError.taxCodeDuplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.TaxCodeDuplicated); } else if (errors.Contains(ProfilerError.uniqueIDduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.MatriculaDuplicated); } else if (errors.Contains(ProfilerError.externalUniqueIDduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.externalUniqueIDduplicate); } else { View.LoadRegistrationMessage(ProfileSubscriptionMessage.UnknownError); } } }
public override List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile) { List <ProfilerError> result = base.VerifyProfileInfo(profile); if (profile.AuthenticationProvider == AuthenticationProviderType.Internal && !isInternalUniqueLogin(profile.Login)) { result.Add(ProfilerError.loginduplicate); } return(result); }
private dtoBaseProfile GetCurrentProfileData(Int32 idProfile, Int32 idProfileType, AuthenticationProviderType type) { dtoBaseProfile oldProfile = null; Person person = CurrentManager.GetPerson(idProfile); if (person != null && idProfileType != (int)UserTypeStandard.Company && idProfileType != (int)UserTypeStandard.Employee) { oldProfile = View.GetOldTypeProfileData(idProfile, idProfileType); } return(Helper.GetCurrentProfileData(idProfile, idProfile, type, oldProfile)); }
public void CreateProfile(dtoBaseProfile profile, Int32 idProfileType, String ProfileName, Int32 idOrganization) { List <ProfilerError> errors = InternalService.VerifyProfileInfo(profile); if (errors.Count == 0) { InternalAuthenticationProvider provider = InternalService.GetActiveProvider(); ProfileSubscriptionMessage message = View.CreateProfile(profile, idProfileType, ProfileName, idOrganization, AuthenticationProviderType.Internal, (provider == null) ? (long)0 : provider.Id); Int32 idPerson = View.IdProfile; if (idPerson > 0) { PolicyService.SaveUserSelection(CurrentManager.GetPerson(idPerson), View.GetPolicyInfo); } if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon && idPerson > 0) { Person person = CurrentManager.GetPerson(View.IdProfile); View.LogonUser(person, provider.Id, lm.Comol.Core.BaseModules.AuthenticationManagement.RootObject.InternalLogin(false), true, CurrentManager.GetUserDefaultIdOrganization(idPerson)); } else { if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon) { message = ProfileSubscriptionMessage.Created; } View.LoadRegistrationMessage(message); } } else { if (errors.Contains(ProfilerError.loginduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.LoginDuplicated); } else if (errors.Contains(ProfilerError.mailDuplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.MailDuplicated); } else if (errors.Contains(ProfilerError.taxCodeDuplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.TaxCodeDuplicated); } else if (errors.Contains(ProfilerError.uniqueIDduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.MatriculaDuplicated); } else { View.LoadRegistrationMessage(ProfileSubscriptionMessage.UnknownError); } } }
public virtual List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile) { List <ProfilerError> result = new List <ProfilerError>(); if (!isUniqueMail(profile.Mail)) { result.Add(ProfilerError.mailDuplicate); } if (!String.IsNullOrEmpty(profile.TaxCode) && !isUniqueTaxCode(profile.TaxCode)) { result.Add(ProfilerError.taxCodeDuplicate); } return(result); }
private void MoveFromStepProfileTypeSelector() { UrlAuthenticationProvider provider = GetProvider(); dtoBaseProfile profile = new dtoBaseProfile(); if (provider != null) { profile.IdProfileType = View.SelectedProfileTypeId; } if (View.SelectedProfileTypeId > 0) { View.GotoStepProfileInfo(profile); } }
//public override Boolean isUniqueTaxCode(string taxCode, long idProvider) //{ // List<Int32> users = (from p in Manager.GetIQ<Person>() where (p.TaxCode == taxCode && !string.IsNullOrEmpty(taxCode)) select p.Id).ToList(); // if (users == null || users.Count == 0) // return true; // else { // return (from u in Manager.GetIQ<ExternalLoginInfo>() // where u.Deleted== BaseStatusDeleted.None && users.Contains(u.Person.Id)) // } //} public virtual List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile, long idProvider) { List <ProfilerError> result = new List <ProfilerError>(); MacUrlAuthenticationProvider provider = Manager.Get <MacUrlAuthenticationProvider>(idProvider); if (!isUniqueMail(profile.Mail)) { result.Add(ProfilerError.mailDuplicate); } if (!String.IsNullOrEmpty(profile.TaxCode) && (provider != null && provider.AllowTaxCodeDuplication) && !isUniqueTaxCode(profile.TaxCode)) { result.Add(ProfilerError.taxCodeDuplicate); } return(result); }
public void CreateProfile(dtoBaseProfile profile, Int32 idProfileType, String ProfileName, Int32 idOrganization) { List <ProfilerError> errors = InternalService.VerifyProfileInfo(profile); if (errors.Count == 0) { ProfileSubscriptionMessage message = View.CreateProfile(profile, idProfileType, ProfileName, idOrganization, View.OtherSelectedOrganizationId, GetAuthenticationProvider(View.SelectedProviderId), View.GetExternalCredentials); Int32 idPerson = View.IdProfile; Person person = CurrentManager.GetPerson(idPerson); if (idPerson > 0 && person != null) { View.LoadProfiles(person); } else { View.LoadRegistrationMessage(message); } } else { if (errors.Contains(ProfilerError.loginduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.LoginDuplicated); } else if (errors.Contains(ProfilerError.mailDuplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.MailDuplicated); } else if (errors.Contains(ProfilerError.taxCodeDuplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.TaxCodeDuplicated); } else if (errors.Contains(ProfilerError.uniqueIDduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.MatriculaDuplicated); } else if (errors.Contains(ProfilerError.externalUniqueIDduplicate)) { View.LoadRegistrationMessage(ProfileSubscriptionMessage.externalUniqueIDduplicate); } else { View.LoadRegistrationMessage(ProfileSubscriptionMessage.UnknownError); } } }
public virtual List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile, long idProvider, dtoExternalCredentials credentials) { List <ProfilerError> result = new List <ProfilerError>(); if (!isUniqueMail(profile.Mail)) { result.Add(ProfilerError.mailDuplicate); } if (!String.IsNullOrEmpty(profile.TaxCode) && !isUniqueTaxCode(profile.TaxCode)) { result.Add(ProfilerError.taxCodeDuplicate); } result.AddRange(VerifyProfileInfo(profile, Manager.Get <AuthenticationProvider>(idProvider), credentials)); return(result); }
public dtoBaseProfile GetProfileData(dtoBaseProfile previous, MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes, Int32 idOrganization, Int32 idProfileType) { dtoBaseProfile result = GetProfileData(provider, pAttributes, attributes, idOrganization, idProfileType); if (previous != null) { result.Id = previous.Id; result.Name = previous.Name; result.Surname = previous.Surname; if (String.IsNullOrEmpty(provider.GetAttributeValue(ProfileAttributeType.taxCode, pAttributes, attributes))) { result.TaxCode = previous.TaxCode; } if (result.Mail == result.Login + "@invalid.invalid.it" && !previous.Mail.Contains("@invalid.invalid.it")) { result.Mail = previous.Mail; } } return(result); }
public virtual List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile, AuthenticationProvider provider, dtoExternalCredentials credentials) { List <ProfilerError> result = new List <ProfilerError>(); if (provider != null) { if (provider.ProviderType == AuthenticationProviderType.Internal && (from ei in Manager.GetIQ <InternalLoginInfo>() where ei.Provider == provider && ei.Login == profile.Login select ei.Id).Any()) { result.Add(ProfilerError.loginduplicate); } else if ((from ei in Manager.GetIQ <ExternalLoginInfo>() where ei.Provider == provider && ei.IdExternalLong == credentials.IdentifierLong && (ei.IdExternalString == credentials.IdentifierString) select ei.Id).Any()) { result.Add(ProfilerError.externalUniqueIDduplicate); } } return(result); }
private PersonInfo GeneratePersonInfo(ProfileAttributesRow row, dtoBaseProfile baseItem) { PersonInfo info = new PersonInfo(); if (baseItem.PersonInfo != null) { info = baseItem.PersonInfo; } else { info.BirthDate = new DateTime(2999, 12, 1); info.BirthPlace = ""; } info.Address = row.GetCellValue(ProfileAttributeType.address); info.City = row.GetCellValue(ProfileAttributeType.city); info.DefaultShowMailAddress = false; info.Fax = row.GetCellValue(ProfileAttributeType.fax); info.PostCode = row.GetCellValue(ProfileAttributeType.zipCode); info.OfficePhone = row.GetCellValue(ProfileAttributeType.telephoneNumber); info.Mobile = row.GetCellValue(ProfileAttributeType.mobile); return(info); }
public virtual List <ProfilerError> VerifyExistingProfile(dtoBaseProfile profile, Boolean verifyTaxCode) { List <ProfilerError> result = new List <ProfilerError>(); if ((from p in Manager.GetIQ <Person>() where p.Mail == profile.Mail && p.Id != profile.Id select p.Id).Any()) { result.Add(ProfilerError.mailDuplicate); } if (verifyTaxCode) { List <MacUrlAuthenticationProvider> mProviders = (from m in Manager.GetIQ <MacUrlAuthenticationProvider>() where m.IsEnabled && m.Deleted == BaseStatusDeleted.None && m.AllowTaxCodeDuplication select m).ToList(); if (mProviders.Count == 0 && (from p in Manager.GetIQ <Person>() where p.TaxCode == profile.TaxCode && p.Id != profile.Id select p.Id).Any()) { result.Add(ProfilerError.taxCodeDuplicate); } else { List <Int32> idUsers = (from p in Manager.GetIQ <Person>() where p.TaxCode == profile.TaxCode && p.Id != profile.Id select p.Id).ToList(); var query = (from e in Manager.GetIQ <ExternalLoginInfo>() where e.Deleted == BaseStatusDeleted.None && e.Person != null && idUsers.Contains(e.Person.Id) select new { IdPerson = e.Person.Id, IdProvider = e.Provider.Id }).ToList(); List <Int32> idProviderUsers = (from e in query where mProviders.Select(p => p.Id).Contains(e.IdProvider) select e.IdPerson).ToList(); if (idUsers.Where(u => !idProviderUsers.Contains(u)).Any()) { result.Add(ProfilerError.taxCodeDuplicate); } } } return(result); }
private List <Person> CreateProfiles(dtoImportSettings settings, Int32 idDefaultOrganization, ProfileExternalResource selectedItems, List <dtoImportedProfile> createdProfiles, List <dtoBaseProfile> notCreatedProfiles) { List <Person> profiles = new List <Person>(); Language language = CurrentManager.GetDefaultLanguage(); AuthenticationProvider provider = Service.GetAuthenticationProvider(settings.IdProvider); if (provider != null && language != null) { Boolean created = false; Int32 idPerson = 0; Int32 index = 1; foreach (ProfileAttributesRow row in selectedItems.Rows) { dtoBaseProfile baseItem = null; switch (settings.IdProfileType) { case (int)UserTypeStandard.ExternalUser: dtoExternal externalUser = CreateExternal(row); baseItem = externalUser; break; case (int)UserTypeStandard.Company: dtoCompany company = CreateCompanyUser(row); baseItem = company; break; case (int)UserTypeStandard.Employee: dtoEmployee employee = CreateEmployee(row); baseItem = employee; break; default: baseItem = new dtoBaseProfile(); break; } created = false; if (baseItem != null) { GenerateBaseProfile(baseItem, settings, row, provider.ProviderType, GetUserLanguage(row, language)); if (InternalService.isUniqueMail(baseItem.Mail)) { PersonInfo info = GeneratePersonInfo(row, baseItem); idPerson = View.AddUserProfile(baseItem, info, idDefaultOrganization, provider); if (idPerson > 0) { Person person = CurrentManager.GetPerson(idPerson); if (person != null) { created = AddAuthentication(person, baseItem, settings, row, provider); if (created) { Service.SetDefaultProvider(provider.Id, person.Id); } profiles.Add(person); createdProfiles.Add(new dtoImportedProfile() { Profile = baseItem, Info = info }); } } } if (!created) { notCreatedProfiles.Add(baseItem); } View.UpdateProfileCreation(0, index, created, baseItem.DisplayName); } else { View.UpdateProfileCreation(0, index, created, " // "); } index++; } } return(profiles); }
public InternalLoginInfo AddInternalProfile(dtoBaseProfile profile, Int32 idPerson) { return(Service.AddInternalProfile(profile, idPerson)); }
private void GenerateBaseProfile(dtoBaseProfile profile, dtoImportSettings settings, ProfileAttributesRow row, AuthenticationProviderType type, Language language) { profile.AuthenticationProvider = type; profile.IdDefaultProvider = settings.IdProvider; profile.IdProfileType = settings.IdProfileType; profile.IdLanguage = language.Id; profile.LanguageName = language.Name; profile.Mail = row.GetCellValue(ProfileAttributeType.mail).Trim(); profile.Name = row.GetCellValue(ProfileAttributeType.name).Trim(); profile.Surname = row.GetCellValue(ProfileAttributeType.surname).Trim(); profile.Sector = row.GetCellValue(ProfileAttributeType.sector); profile.Job = row.GetCellValue(ProfileAttributeType.job); if (profile.PersonInfo == null) { profile.PersonInfo = new PersonInfo(); } string birthOn = row.GetCellValue(ProfileAttributeType.birthDate); DateTime birthDate = DefaultBirthDate; try { birthDate = System.DateTime.Parse(birthOn); } catch (Exception) { birthDate = DefaultBirthDate; } profile.PersonInfo.BirthDate = birthDate; profile.PersonInfo.BirthPlace = row.GetCellValue(ProfileAttributeType.birthPlace); if (!String.IsNullOrEmpty(profile.Name)) { profile.Name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(profile.Name); } if (!String.IsNullOrEmpty(profile.Surname)) { profile.Surname = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(profile.Surname); } if (type == AuthenticationProviderType.Internal) { profile.Password = (settings.AddPassword) ? row.GetCellValue(ProfileAttributeType.password) : lm.Comol.Core.DomainModel.Helpers.RandomKeyGenerator.GenerateRandomKey(6, 10, true, true, false); profile.Login = (settings.AutoGenerateLogin) ? row.GetCellValue(ProfileAttributeType.autoGeneratedLogin) : row.GetCellValue(ProfileAttributeType.login); if (string.IsNullOrEmpty(profile.Login)) { profile.Login = InternalService.GenerateInternalLogin(profile.Name, profile.Surname); } else if (!InternalService.isInternalUniqueLogin(profile.Login)) { profile.Login = InternalService.GenerateInternalLogin(profile.Name, profile.Surname); } } else { profile.Login = row.GetCellValue(ProfileAttributeType.externalId); } profile.ShowMail = false; if (!string.IsNullOrEmpty(profile.Surname)) { profile.FirstLetter = profile.Surname[0].ToString().ToLower(); } profile.TaxCode = row.GetCellValue(ProfileAttributeType.taxCode); //if (settings.AddTaxCode) // profile.TaxCode = row.GetCellValue(ProfileAttributeType.taxCode); if (String.IsNullOrEmpty(profile.TaxCode)) { profile.TaxCode = InternalService.GenerateRandomTaxCode(); } while (!InternalService.isUniqueTaxCode(profile.TaxCode)) { profile.TaxCode = InternalService.GenerateRandomTaxCode(); } }
private Boolean EditProfileType(Int32 idProfile, Int32 idNewType, Int32 idOrganization, MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes) { Boolean result = false; ProfileTypeChanger person = CurrentManager.Get <ProfileTypeChanger>(idProfile); Int32 idOldType = person.TypeID; dtoBaseProfile profile = GetCurrentProfileData(idProfile, idOldType, provider.ProviderType); if (idProfile > 0 && person != null) { Person people = CurrentManager.GetPerson(idProfile); if (people != null) { CurrentManager.Detach(people); } if (person.TypeID == (int)UserTypeStandard.Company && idNewType != (int)UserTypeStandard.Company) { person = ProfileService.EditProfileType(person, idNewType); } else if (idNewType == (int)UserTypeStandard.Company) { person = ProfileService.EditProfileType(person, idNewType); } else if (person.TypeID == (int)UserTypeStandard.Employee && idNewType != (int)UserTypeStandard.Employee) { person = ProfileService.EditProfileType(person, idNewType); } else if (idNewType == (int)UserTypeStandard.Employee) { person = ProfileService.EditProfileType(person, idNewType); } if (idOldType != idNewType && person != null) { if (idNewType == (int)UserTypeStandard.Company) { dtoCompany company = (dtoCompany)Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType); if (idOldType == (int)UserTypeStandard.Employee || View.DeletePreviousProfileType(idProfile, idOldType, idNewType)) { result = (ProfileService.SaveCompanyUser(company, null) != null); } } else if (idNewType == (int)UserTypeStandard.Employee) { dtoEmployee employee = (dtoEmployee)Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType); if (idOldType == (int)UserTypeStandard.Company || View.DeletePreviousProfileType(idProfile, idOldType, idNewType)) { Employee savedEmployee = ProfileService.SaveEmployee(employee, null); if (savedEmployee != null) { //long idAgency = employee.CurrentAgency.Key; //if (idAgency < 1) // idAgency = ProfileService.GetEmptyAgency(0).Key; //SaveAgencyAffiliation(employee.CurrentAgency.Key, IdProfile); UpdateAgencyAssocation(idProfile, idOrganization, provider, attributes); } result = (savedEmployee != null); } } else { result = View.EditProfileType(idProfile, Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType), idOldType, idNewType); } if (result && idOldType == (int)UserTypeStandard.Employee) { ProfileService.CloseEmployeeAffiliations(idProfile); } } } return(result); }
public dtoBaseProfile GetProfileData(MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes, Int32 idOrganization, Int32 idProfileType) { dtoBaseProfile profile = new dtoBaseProfile(); String pwd = lm.Comol.Core.DomainModel.Helpers.RandomKeyGenerator.GenerateRandomKey(6, 10, true, true, false); Language language = GetUserLanguage(provider.GetAttributeValue(ProfileAttributeType.language, pAttributes, attributes)); switch (idProfileType) { case (int)UserTypeStandard.ExternalUser: profile = new dtoExternal(); break; case (int)UserTypeStandard.Company: profile = new dtoCompany(); break; case (int)UserTypeStandard.Employee: profile = new dtoEmployee(); break; default: profile = new dtoBaseProfile(); break; } profile.Login = provider.GetAttributeValue(ProfileAttributeType.login, pAttributes, attributes); if (String.IsNullOrEmpty(profile.Login)) { profile.Login = provider.GetAttributeValue(ProfileAttributeType.externalId, attributes); } profile.Name = provider.GetAttributeValue(ProfileAttributeType.name, pAttributes, attributes); profile.Surname = provider.GetAttributeValue(ProfileAttributeType.surname, pAttributes, attributes); profile.TaxCode = provider.GetAttributeValue(ProfileAttributeType.taxCode, pAttributes, attributes); if (String.IsNullOrEmpty(profile.TaxCode)) { profile.TaxCode = UrlService.GenerateRandomTaxCode(); } profile.Mail = provider.GetAttributeValue(ProfileAttributeType.mail, pAttributes, attributes); if (String.IsNullOrEmpty(profile.Mail)) { profile.Mail = profile.Login + "@invalid.invalid.it"; } //if (!String.IsNullOrEmpty(profile.Mail)) // profile.Mail = profile.Mail.ToLower(); profile.Password = pwd; profile.ShowMail = false; if (!String.IsNullOrEmpty(profile.Surname)) { profile.FirstLetter = profile.Surname[0].ToString().ToLower(); } profile.IdProfileType = idProfileType; profile.AuthenticationProvider = provider.ProviderType; profile.IdLanguage = language.Id; profile.LanguageName = language.Name; switch (idProfileType) { case (int)UserTypeStandard.Company: dtoCompany dCompany = (dtoCompany)profile; dCompany.Info.Address = provider.GetAttributeValue(ProfileAttributeType.companyAddress, pAttributes, attributes); dCompany.Info.City = provider.GetAttributeValue(ProfileAttributeType.companyCity, pAttributes, attributes); dCompany.Info.Name = provider.GetAttributeValue(ProfileAttributeType.companyName, pAttributes, attributes); dCompany.Info.Region = provider.GetAttributeValue(ProfileAttributeType.companyRegion, pAttributes, attributes); dCompany.Info.TaxCode = provider.GetAttributeValue(ProfileAttributeType.companyTaxCode, pAttributes, attributes); dCompany.Info.ReaNumber = provider.GetAttributeValue(ProfileAttributeType.companyReaNumber, pAttributes, attributes); dCompany.Info.AssociationCategories = provider.GetAttributeValue(ProfileAttributeType.companyAssociations, pAttributes, attributes); return(dCompany); case (int)UserTypeStandard.Employee: dtoEmployee dEmployee = (dtoEmployee)profile; Person anonymous = ProfileService.GetAnonymousUser(); Agency agency = null; if (anonymous == null) { Dictionary <ProfileAttributeType, string> agencyAttributes = GetUserAttributesForAgency(provider, attributes); agency = ProfileService.GetAgency(agencyAttributes); if (agency == null) { agency = ProfileService.GetDefaultAgency(idOrganization); } } else { agency = GetAgencyByAttributes(anonymous.Id, idOrganization, provider, attributes); } if (agency != null) { dEmployee.CurrentAgency = new KeyValuePair <long, string>(agency.Id, agency.Name); } else { dEmployee.CurrentAgency = ProfileService.GetEmptyAgency(idOrganization); } return(dEmployee); case (int)UserTypeStandard.ExternalUser: dtoExternal dExternal = (dtoExternal)profile; dExternal.ExternalUserInfo = provider.GetAttributeValue(ProfileAttributeType.externalUserInfo, pAttributes, attributes); return(dExternal); default: return(profile); } }