pythonpyad

Python pyad module can't set UPN


I am using pyad module in order to create active directory. I have one issue, I am not able to properly set the UPN suffix to @mycompany.local

Here is the code :

new_user = pyad.adcontainer.ADUser.create("Hugo Test", ou, password="Passw0rd", upn_suffix="@mycompany.local", optional_attributes = {"samaccountname":"htest","userPrincipalName":"htest","givenname":"Hugo","sn":"Test","displayName":"Hugo Test"})

The user is created without any issue, but the UPN suffixes remain empty on my active directory.

Active directory : 2012

Pyad : 0.5.15

python : 3.5.2

Any idea on what is going wrong ?


Solution

  • Ok, I will answer to my own question. I solved this by setting the UPN suffix in the userPrincipalName so the code looks like :

    new_user = pyad.adcontainer.ADUser.create("Hugo Test", ou, password="Passw0rd", upn_suffix="@mycompany.local", optional_attributes = {"samaccountname":"htest","userPrincipalName":"htest@mycompany.local","givenname":"Hugo","sn":"Test","displayName":"Hugo Test"})