Skip to content

Commit

Permalink
Handle case where netbiosalias is omitted from AD payload
Browse files Browse the repository at this point in the history
When netbiosalias is set in SMB configuration and omitted from the
payload in the AD form, it gets populated as an empty list causing
a ValidationError to be raised (because we don't allow changing
netbios configuration while AD is enabled). Unfortunately, some
howto guides online have recommended users to set the netbiosname
netbios alias to the same value, and as is the way of such things
this advice is both unnecessary and detremental. This means that users
who followed such guides are now unable to modify their AD configuration
through the webui (which no longer sets the netbiosalias by default).

Set the default for netbiosalias to None so that it does not default
to an empty list as a special value indicating that the existing
netbios aliases should be preserved.

(cherry picked from commit 4226eb0)
  • Loading branch information
anodos325 authored and bugclerk committed Nov 21, 2024
1 parent e196a9c commit 94eb633
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/middlewared/middlewared/plugins/activedirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Config:
Str('createcomputer'),
NetbiosName('netbiosname'),
NetbiosName('netbiosname_b'),
List('netbiosalias', items=[NetbiosName('alias')]),
List('netbiosalias', items=[NetbiosName('alias')], default=None),
Bool('enable'),
register=True
)
Expand Down Expand Up @@ -122,6 +122,11 @@ async def nss_info_choices(self):
@private
async def update_netbios_data(self, old, new):
must_update = False

# None here as opposed to empty list indicates to preserve current value
if new['netbiosalias'] is None:
new['netbiosalias'] = old['netbiosalias']

for key in ['netbiosname', 'netbiosalias']:
# netbios names are case-insensitive
if key in new and old[key] != new[key]:
Expand Down

0 comments on commit 94eb633

Please sign in to comment.