mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-31 23:41:09 +02:00
Extract email for active directory users that don't have access to exchange (#3053)
This commit is contained in:
parent
bec4a29f19
commit
8567b56b8d
2 changed files with 15 additions and 5 deletions
|
@ -31,15 +31,17 @@ func (obj apiUser) getEmail() string {
|
|||
|
||||
// AD often doesn't have the email address returned, but we can parse it from the UPN
|
||||
|
||||
// UPN looks like:
|
||||
// UPN looks like either:
|
||||
// cdoxsey_pomerium.com#EXT#@cdoxseypomerium.onmicrosoft.com
|
||||
// cdoxsey@pomerium.com
|
||||
email := obj.UserPrincipalName
|
||||
if idx := strings.Index(email, "#EXT"); idx > 0 {
|
||||
email = email[:idx]
|
||||
}
|
||||
// find the last _ and replace it with @
|
||||
if idx := strings.LastIndex(email, "_"); idx > 0 {
|
||||
email = email[:idx] + "@" + email[idx+1:]
|
||||
|
||||
// find the last _ and replace it with @
|
||||
if idx := strings.LastIndex(email, "_"); idx > 0 {
|
||||
email = email[:idx] + "@" + email[idx+1:]
|
||||
}
|
||||
}
|
||||
return email
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue