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

support for pointer fields with Entry.Unmarshal #475

Closed
lrstanley opened this issue Nov 26, 2023 · 0 comments · Fixed by #476
Closed

support for pointer fields with Entry.Unmarshal #475

lrstanley opened this issue Nov 26, 2023 · 0 comments · Fixed by #476

Comments

@lrstanley
Copy link

I have a service which syncs various data from LDAP into a database on a given interval. We sync roughly 50,000 users, and 48,000 groups from LDAP during this process, and it's a hit or miss on the standards for how these will show up. An example of one of the structs that's used as part of the Entry.Unmarshal() process:

type UserLDAP struct {
	ObjectGUID        string  `json:"object_guid"         ldap:"objectGUID"`
	CommonName        string  `json:"common_name"         ldap:"cn"`
	Description       *string `json:"description"         ldap:"description"`
	DisplayName       *string `json:"display_name"        ldap:"displayName"`
	DistinguishedName string  `json:"distinguished_name"  ldap:"distinguishedName"`
	Mail              *string `json:"mail"                ldap:"mail"`
	SAMAccountName    string  `json:"sam_account_name"    ldap:"sAMAccountName"`
	UserPrincipalName string  `json:"user_principal_name" ldap:"userPrincipalName"`
	ThumbnailPhoto    []byte  `json:"thumbnail_photo"     ldap:"thumbnailPhoto"`
}

The idea is that for the fields which aren't actually defined in the source object within LDAP/AD, those would be nillable within the struct, and I could easily determine if something is set, but an empty string, vs not set (for example).

However, with v3.4.6 today, this results in the following, which means we have to do checks against many fields to see if they are empty (and still can't tell if it was originally set or not):

ldap: expected field to be of type string, []string, int, int64, []byte, *DN, []*DN or time.Time, got *string

Would it be possible to support nillable fields, or is there some lower level protocol issue with doing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants