Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check nsAccountLock attribute for user status #89

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pkg/connector/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
attrUserPrincipalName = "userPrincipalName"
attrUserAccountControl = "userAccountControl"
attrUserLastLogon = "lastLogonTimestamp"

// FreeIPA (Red Hat Identity) specific attributes

Check failure on line 44 in pkg/connector/user.go

View workflow job for this annotation

GitHub Actions / go-lint

Comment should end in a period (godot)
attrNSAccountLock = "nsAccountLock"

Check failure on line 45 in pkg/connector/user.go

View workflow job for this annotation

GitHub Actions / go-lint

File is not properly formatted (goimports)
)

var allAttrs = []string{"*", "+"}
Expand Down Expand Up @@ -75,8 +78,10 @@
func parseUserStatus(user *ldap.Entry) (v2.UserTrait_Status_Status, error) {
userStatus := v2.UserTrait_Status_STATUS_UNSPECIFIED

// Currently only UserAccountControlFlag from Microsoft is supported
// Currently only UserAccountControlFlag from Microsoft or nsAccountLock from FreeIPA is supported
userAccountControlFlag := user.GetEqualFoldAttributeValue(attrUserAccountControl)
nsAccountLockFlag := user.GetEqualFoldAttributeValue(attrNSAccountLock)

if userAccountControlFlag != "" {
userAccountControlFlag, err := strconv.ParseInt(userAccountControlFlag, 10, 64)
if err != nil {
Expand All @@ -90,7 +95,15 @@
userStatus = v2.UserTrait_Status_STATUS_DISABLED
}
return userStatus, nil
} else if nsAccountLockFlag != "" {
locked, _ := strconv.ParseBool(nsAccountLockFlag)
if locked {
userStatus = v2.UserTrait_Status_STATUS_DISABLED
} else {
userStatus = v2.UserTrait_Status_STATUS_ENABLED
}
}

return userStatus, nil
}

Expand Down
Loading