Dear All,
When using the API to create an account, if I don't specify the uidnumber I get this error:
missing attribute "uidNumber" required by object class "posixAccount"
I was expecting the uidNumber to function thus: "system will assign one if not provided"
Am I missing something?
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.ukmailto:callum@well.ox.ac.uk
Callum Smith via FreeIPA-users wrote:
Dear All,
When using the API to create an account, if I don't specify the uidnumber I get this error:
missing attribute "uidNumber" required by object class "posixAccount"
I was expecting the uidNumber to function thus: "system will assign one if not provided"
Am I missing something?
You need to set uidnumber to -1 to have DNA automatically assign a value (pre v3.2 the magic number is 999).
rob
Dear Rob,
Running v4.5.0 (CentOS 7.4 distribution) API version 2.228
Setting it to -1 gives: ValidationError: invalid 'uid': must be at least 1
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.ukmailto:callum@well.ox.ac.uk
On 24 Oct 2018, at 12:47, Rob Crittenden <rcritten@redhat.commailto:rcritten@redhat.com> wrote:
Callum Smith via FreeIPA-users wrote: Dear All,
When using the API to create an account, if I don't specify the uidnumber I get this error:
missing attribute "uidNumber" required by object class "posixAccount"
I was expecting the uidNumber to function thus: "system will assign one if not provided"
Am I missing something?
You need to set uidnumber to -1 to have DNA automatically assign a value (pre v3.2 the magic number is 999).
rob
Callum Smith wrote:
Dear Rob,
Running v4.5.0 (CentOS 7.4 distribution) API version 2.228
Setting it to -1 gives: ValidationError: invalid 'uid': must be at least 1
Need more information on what exactly it is you are doing.
rob
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.uk mailto:callum@well.ox.ac.uk
On 24 Oct 2018, at 12:47, Rob Crittenden <rcritten@redhat.com mailto:rcritten@redhat.com> wrote:
Callum Smith via FreeIPA-users wrote:
Dear All,
When using the API to create an account, if I don't specify the uidnumber I get this error:
missing attribute "uidNumber" required by object class "posixAccount"
I was expecting the uidNumber to function thus: "system will assign one if not provided"
Am I missing something?
You need to set uidnumber to -1 to have DNA automatically assign a value (pre v3.2 the magic number is 999).
rob
Dear Rob,
I'm using the python-freeipa library:
(client is initialised and logged in - tested and working with other calls such as user_show etc)
client.user_add( options.username, options.first_name, options.last_name, options.name, mail=options.mail, home_directory=options.home_directory, uidnumber=options.uid if options.uid else -1, gidnumber=options.primary_gid, user_password=options.password, )
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.ukmailto:callum@well.ox.ac.uk
On 24 Oct 2018, at 13:32, Rob Crittenden <rcritten@redhat.commailto:rcritten@redhat.com> wrote:
Callum Smith wrote: Dear Rob,
Running v4.5.0 (CentOS 7.4 distribution) API version 2.228
Setting it to -1 gives: ValidationError: invalid 'uid': must be at least 1
Need more information on what exactly it is you are doing.
rob
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.ukmailto:callum@well.ox.ac.uk mailto:callum@well.ox.ac.uk
On 24 Oct 2018, at 12:47, Rob Crittenden <rcritten@redhat.commailto:rcritten@redhat.com mailto:rcritten@redhat.com> wrote:
Callum Smith via FreeIPA-users wrote: Dear All,
When using the API to create an account, if I don't specify the uidnumber I get this error:
missing attribute "uidNumber" required by object class "posixAccount"
I was expecting the uidNumber to function thus: "system will assign one if not provided"
Am I missing something?
You need to set uidnumber to -1 to have DNA automatically assign a value (pre v3.2 the magic number is 999).
rob
On ke, 24 loka 2018, Callum Smith via FreeIPA-users wrote:
Dear Rob,
I'm using the python-freeipa library:
(client is initialised and logged in - tested and working with other calls such as user_show etc)
client.user_add( options.username, options.first_name, options.last_name, options.name, mail=options.mail, home_directory=options.home_directory, uidnumber=options.uid if options.uid else -1, gidnumber=options.primary_gid, user_password=options.password, )
Sorry, this is not an API provided by the FreeIPA project. Please contact authors of python-freeipa (I think it was created by OpenNode people) and report them bugs you see there.
https://pypi.org/project/python-freeipa/
Dear Alexander,
The issue is not with the library (it does no validation of syntax) the error I have provided is verbose directly from the FreeIPA API response.
How would you suggest I re-factor this code so that the error is acceptable?
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.ukmailto:callum@well.ox.ac.uk
On 24 Oct 2018, at 17:54, Alexander Bokovoy <abokovoy@redhat.commailto:abokovoy@redhat.com> wrote:
On ke, 24 loka 2018, Callum Smith via FreeIPA-users wrote: Dear Rob,
I'm using the python-freeipa library:
(client is initialised and logged in - tested and working with other calls such as user_show etc)
client.user_add( options.username, options.first_name, options.last_name, options.name, mail=options.mail, home_directory=options.home_directory, uidnumber=options.uid if options.uid else -1, gidnumber=options.primary_gid, user_password=options.password, ) Sorry, this is not an API provided by the FreeIPA project. Please contact authors of python-freeipa (I think it was created by OpenNode people) and report them bugs you see there.
https://pypi.org/project/python-freeipa/
-- / Alexander Bokovoy Sr. Principal Software Engineer Security / Identity Management Engineering Red Hat Limited, Finland
On to, 25 loka 2018, Callum Smith wrote:
Dear Alexander,
The issue is not with the library (it does no validation of syntax) the error I have provided is verbose directly from the FreeIPA API response.
It seems the library puts some defaults that aren't accepted by the FreeIPA API, unlike a client code we provide. Or may be that's your use of it. More below.
How would you suggest I re-factor this code so that the error is acceptable?
Looking at the definition of 'uidnumber' parameter to user object, we can see it has minimal value of '1' and it is optional (? at the end of the name):
Int('uidnumber?', cli_name='uid', label=_('UID'), doc=_('User ID Number (system will assign one if not provided)'), minvalue=1, ),
This means that if you wouldn't provide it in your request, it will be automatically generated.
So a simple approach would be replace explicit addition of named arguments by a dict and then adding that dict:
opts = {} if options.uid: opts['uidnumber'] = options.uid opts['gidnumber'] = options.primary_gid opts['mail'] = options.mail opts['home_directory'] = options.home_directory opts['user_password'] = options.password ...
client.user_add(...., **opts)
(client is initialised and logged in - tested and working with other calls such as user_show etc)
client.user_add( options.username, options.first_name, options.last_name, options.name, mail=options.mail, home_directory=options.home_directory, uidnumber=options.uid if options.uid else -1, gidnumber=options.primary_gid, user_password=options.password, ) Sorry, this is not an API provided by the FreeIPA project. Please contact authors of python-freeipa (I think it was created by OpenNode people) and report them bugs you see there.
https://pypi.org/project/python-freeipa/
-- / Alexander Bokovoy Sr. Principal Software Engineer Security / Identity Management Engineering Red Hat Limited, Finland
Alexander Bokovoy wrote:
On to, 25 loka 2018, Callum Smith wrote:
Dear Alexander,
The issue is not with the library (it does no validation of syntax) the error I have provided is verbose directly from the FreeIPA API response.
It seems the library puts some defaults that aren't accepted by the FreeIPA API, unlike a client code we provide. Or may be that's your use of it. More below.
How would you suggest I re-factor this code so that the error is acceptable?
Looking at the definition of 'uidnumber' parameter to user object, we can see it has minimal value of '1' and it is optional (? at the end of the name):
Int('uidnumber?', cli_name='uid', label=_('UID'), doc=_('User ID Number (system will assign one if not provided)'), minvalue=1, ),
This means that if you wouldn't provide it in your request, it will be automatically generated.
Right, I suggested -1 to see if it would help (it didn't and IPA rejected it in input validation).
So a simple approach would be replace explicit addition of named arguments by a dict and then adding that dict:
opts = {} if options.uid: opts['uidnumber'] = options.uid opts['gidnumber'] = options.primary_gid opts['mail'] = options.mail opts['home_directory'] = options.home_directory opts['user_password'] = options.password ...
client.user_add(...., **opts)
(client is initialised and logged in - tested and working with other calls such as user_show etc)
client.user_add( options.username, options.first_name, options.last_name, options.name, mail=options.mail, home_directory=options.home_directory, uidnumber=options.uid if options.uid else -1, gidnumber=options.primary_gid, user_password=options.password, ) Sorry, this is not an API provided by the FreeIPA project. Please contact authors of python-freeipa (I think it was created by OpenNode people) and report them bugs you see there.
https://pypi.org/project/python-freeipa/
-- / Alexander Bokovoy Sr. Principal Software Engineer Security / Identity Management Engineering Red Hat Limited, Finland
Dear Alexander,
You're exactly right, failure on my part to understand how the module underneath was parsing keyword arguments (and that the attribute had to be specifically omitted and not just a None value).
Thanks for your help, all working fine now.
Regards, Callum
--
Callum Smith Research Computing Core Wellcome Trust Centre for Human Genetics University of Oxford e. callum@well.ox.ac.ukmailto:callum@well.ox.ac.uk
On 25 Oct 2018, at 08:38, Alexander Bokovoy <abokovoy@redhat.commailto:abokovoy@redhat.com> wrote:
On to, 25 loka 2018, Callum Smith wrote: Dear Alexander,
The issue is not with the library (it does no validation of syntax) the error I have provided is verbose directly from the FreeIPA API response.
It seems the library puts some defaults that aren't accepted by the FreeIPA API, unlike a client code we provide. Or may be that's your use of it. More below.
How would you suggest I re-factor this code so that the error is acceptable?
Looking at the definition of 'uidnumber' parameter to user object, we can see it has minimal value of '1' and it is optional (? at the end of the name):
Int('uidnumber?', cli_name='uid', label=_('UID'), doc=_('User ID Number (system will assign one if not provided)'), minvalue=1, ),
This means that if you wouldn't provide it in your request, it will be automatically generated.
So a simple approach would be replace explicit addition of named arguments by a dict and then adding that dict:
opts = {} if options.uid: opts['uidnumber'] = options.uid opts['gidnumber'] = options.primary_gid opts['mail'] = options.mail opts['home_directory'] = options.home_directory opts['user_password'] = options.password ...
client.user_add(...., **opts)
(client is initialised and logged in - tested and working with other calls such as user_show etc)
client.user_add( options.username, options.first_name, options.last_name, options.name, mail=options.mail, home_directory=options.home_directory, uidnumber=options.uid if options.uid else -1, gidnumber=options.primary_gid, user_password=options.password, ) Sorry, this is not an API provided by the FreeIPA project. Please contact authors of python-freeipa (I think it was created by OpenNode people) and report them bugs you see there.
https://pypi.org/project/python-freeipa/
-- / Alexander Bokovoy Sr. Principal Software Engineer Security / Identity Management Engineering Red Hat Limited, Finland
-- / Alexander Bokovoy Sr. Principal Software Engineer Security / Identity Management Engineering Red Hat Limited, Finland
freeipa-users@lists.fedorahosted.org