Skip to content

Commit

Permalink
Do casefolded comparison of netbios names (#14992)
Browse files Browse the repository at this point in the history
There has been an uptick in users complaining about hitting the
activedirectory validation error that gets triggered when trying
to change the server netbiosname while it is enabled.
Make sure we're doing case-insensitive comparison for old and new
names and include the names in the ValidationError message.
  • Loading branch information
anodos325 authored Nov 20, 2024
1 parent 578b818 commit 6ec619f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/middlewared/middlewared/plugins/activedirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,26 @@ async def nss_info_choices(self):
async def update_netbios_data(self, old, new):
must_update = False
for key in ['netbiosname', 'netbiosalias']:
# netbios names are case-insensitive
if key in new and old[key] != new[key]:
if old['enable']:
raise ValidationError(
f'activedirectory.{key}',
'NetBIOS names may not be changed while service is enabled.'
)
if key == 'netbiosname' and new[key].casefold() != old[key].casefold():
raise ValidationError(
f'activedirectory.{key}',
f'{old[key]} -> {new[key]}: NetBIOS name may not be changed while service is enabled.'
)
elif len(old[key]) != len(new[key]):
raise ValidationError(
f'activedirectory.{key}',
f'{old[key]} -> {new[key]}: NetBIOS aliases may not be changed while service is enabled.'
)
else:
for idx, alias in enumerate(old[key]):
if old[key][idx].casefold() != new[key][idx].casefold():
raise ValidationError(
f'activedirectory.{key}.{idx}',
f'{old[key][idx]} -> {new[key][idx]}: NetBIOS alias may not be changed while service is enabled.'
)

must_update = True
break
Expand Down

0 comments on commit 6ec619f

Please sign in to comment.