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

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -