AuthenticationUserCreateOrUpdateResult GetOrCreateUser(UserPrincipal principal, string fallbackUsername, string fallbackDomain) { var username = objectNameNormalizer.ValidatedUserPrincipalName(principal, fallbackUsername, fallbackDomain); var externalId = principal.SamAccountName; if (!string.IsNullOrWhiteSpace(fallbackDomain)) { externalId = fallbackDomain + @"\" + externalId; } var displayName = string.IsNullOrWhiteSpace(principal.DisplayName) ? principal.Name : principal.DisplayName; var emailAddress = principal.EmailAddress; if (string.IsNullOrWhiteSpace(externalId)) { log.Error($"We couldn't find a valid external identity to use for the Active Directory user '{displayName}' with email address '{emailAddress}' for the Octopus User Account named '{username}'. Octopus uses the samAccountName (pre-Windows 2000 Logon Name) as the external identity for Active Directory users. Please make sure this user has a valid samAccountName and try again. Learn more about troubleshooting Active Directory authentication at http://g.octopushq.com/TroubleshootingAD"); } return(new AuthenticationUserCreateOrUpdateResult(userStore.CreateOrUpdate( username, displayName, emailAddress, externalId, null, true, null, false, new string[0]))); }
UserCreateOrUpdateResult GetOrCreateUser(UserPrincipal principal, string fallbackUsername, string fallbackDomain) { var name = credentialNormalizer.ValidatedUserPrincipalName(principal, fallbackUsername, fallbackDomain); return(userStore.CreateOrUpdate( name, string.IsNullOrWhiteSpace(principal.DisplayName) ? principal.Name : principal.DisplayName, principal.EmailAddress, principal.SamAccountName, null, true, null, false, new string[0])); }
UserCreateOrUpdateResult GetOrCreateUser(UserResource userResource, ClaimsPrincipal principal) { var groups = principal.FindAll(ClaimTypes.Role).Select(c => c.Value).ToArray(); var userResult = userStore.CreateOrUpdate( userResource.Username, userResource.DisplayName, userResource.EmailAddress, userResource.ExternalId, null, true, null, false, groups); return(userResult); }