0

I'm able to rename a CN for a user when it doesn't have a comma, but some of our users were previously entered as "Lastname, Firstname" and none of those will work when attempting to rename them. I tried escaping the comma with a backslash per some related topics I found regarding moving or creating users with commas, but nothing really seems to work with renaming them.

The error I get is... 'An invalid dn syntax has been specified.\r\n', None, 0, -2147016654), None

I tried poking around at some of the files in the PYAD library and printing out some variables it was using in some of the relevant functions, and at some point it seems to be leaving out the last name and the comma and it just has the first name with a space in front of it, and then it can't find that. I don't know enough beyond that to approach how to fix it or work around it.

elbow
  • 1
  • 1
  • You'll need to show your code before anyone will be able to help. – Gabriel Luci Jul 27 '22 at 15:27
  • this works: `pyad.from_cn('jdoe').rename('newname')` This, and other cases where there is a comma, does not: `pyad.from_cn('Lastname, Firstname').rename('newname')` – elbow Jul 27 '22 at 15:36
  • What happens when you try escaping the comma? `pyad.from_cn('Lastname\, Firstname').rename('newname')` – Gabriel Luci Jul 27 '22 at 15:48
  • I still get an error, but it is different: `AttributeError: 'NoneType' object has no attribute 'rename'` – elbow Jul 27 '22 at 15:50
  • Looking at the source code for pyad, that makes sense. Does `pyad.from_cn('Lastname, Firstname')` by itself (without `.rename()`) work? It seems like it should. – Gabriel Luci Jul 27 '22 at 15:52
  • Also, does your new name have a comma or anything special about it? – Gabriel Luci Jul 27 '22 at 15:53
  • It seems to work in other cases. for example, I can display an email address with `print(pyad.from_cn('Firstname, Lastname').get_attribute("mail"))` The new name does not have a comma or any special/forbidden characters. – elbow Jul 27 '22 at 16:01
  • Does the OU it's in have any special characters? – Gabriel Luci Jul 27 '22 at 16:08
  • Nope, the entire path just contains some upper and lower case letters. Not even so much as a space or period or hyphen or anything like that. – elbow Jul 27 '22 at 16:15
  • That kind of seems like a bug in pyad. If you use `pyad.from_dn` to find the object instead of `from_cn`, does it work? – Gabriel Luci Jul 27 '22 at 16:21
  • I seem to get that same first error: `'An invalid dn syntax has been specified.\r\n', None, 0, -2147016654), None` – elbow Jul 27 '22 at 16:34
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 27 '22 at 18:38

0 Answers0