Only one attribute per Change allowed

Viewed 28

screenshot

client.modify(userDN, [
                            new ldap.Change({
                                operation: 'replace',
                                modification: {
                                    uid: args.userId,
                                    sn: args.userGroup,
                                    givenName: args.userSubGroup,
                                    employeeType: args.userType,
                                    description: JSON.stringify(args.permissions),
                                    mobile: args.mobileNo,
                                    cn: args.name,
                                    mail: args.emailId,
                                    title: args.status,
                                    o: args.orgId,
                                    homePostalAddress: args.addedOn,
                                    initials: args.userGroup,
                                    pager: args.modifiedOn,
                                    userPassword: args.passwordHash,
                                }
                            }),
2 Answers

The message is correct. An LDAP Modify operation consists of multiple 'changes', and each 'change' applies to one attribute. For example, an LDIF that looks like this:

dn: THE_USER_DN
changeType: modify
-
replace: uid
uid: THE_USER_ID
-
replace: sn
sn: THE_FAMILY_NAME
-

would correspond to code similar to:

client.modify(userDN, [
    new ldap.Change({operation: 'replace',
                     modification: {uid: args.userId}}),
    new ldap.Change({operation: 'replace',
                     modification: {sn: args.familyName}}),
    new ldap.Change({operation: 'replace',
                     modification: {cn: args.fullName}}),
])

(I don't know if this is 100% correct, as you didn't even specify what programming language it's written in, but it looks about right.)

This is working code for multiple attributes changes in ldap:

client.modify(userDN,[
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        sn: args.userGroup,
                                    }
                                }),
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        givenName: args.userSubGroup,
                                    }
                                }),
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        employeeType: args.userType,
                                    }
                                }),
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        description: JSON.stringify(args.permissions),
                                    }
                                }),
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        mobile: args.mobileNo,
                                    }
                                }),
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        cn: args.name,
                                    }
                                }),
                                new ldap.Change({
                                    operation: 'replace',
                                    modification: {
                                        mail: args.emailId,
                                    }
                                })
                            
                            ],
                            
                    });
Related