c# - AccountManagement create user return 'object already exists' exception -


i'm trying create new userprincipal in specific ou inside activedirectory, , returns exception message 'object exists'. (obviously) user don't exists in ou, , i'm testing existence.

what doing wrong?

here's code throwing exception:

public userprincipal createuser(string username, string pass,         string givenname, string surname) {     principalcontext context = this.principalcontext;     userprincipal user = new userprincipal(context);     user.samaccountname = username;     user.userprincipalname = username;     user.givenname = givenname;     user.surname = surname;     user.setpassword(pass);     user.save();     return user; } 

edit 1: after unit tests, found code ok. use method in lib (where run tests), called application, has windows authentication mode enabled. maybe app sending authentication ad?

samaccountname must unique across enterprise. mention 'specific ou' when creating user. possible have user same username/samaccountname in different ou?


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -