Hi!!
I developed a C# aplication to create users in active directory and el
following code create a user and a mailbox.
NewUser.Properties["userPrincipalName"].Value = userName+"@pruebas.es";
NewUser.Properties["name"].Value = name;
NewUser.Properties["samAccountName"].Value = userName;
NewUser.Properties["description"].Value=description;
NewUser.Properties["pwdLastSet"].Value = -1;
NewUser.Properties["givenName"].Value=name;
NewUser.CommitChanges();
NewUser.Invoke("ChangePassword", new object[] {"",password});
NewUser.CommitChanges();
NewUser.Properties["userAccountControl"].Value=0x200;
NewUser.CommitChanges();
CDOEXM.IMailboxStore mailbox;
mailbox = (IMailboxStore)NewUser.NativeObject;
mailbox.CreateMailbox(homeMDB);
NewUser.CommitChanges();
The problem is that now I'm testing this code in other domain control and
it's doesn't work!!!
My question is, my code is correct? or can be a problem of the domain
controler? (permissions...)
Thanks in advance
"Marc Scheuner" escribió:
>In our development environment we are able to bind to AD using LDAP and
create a new directory entry.
> >We comit this and the DirectoryEntry is created using a blank password as shown below:
> >We are then able to Invoke SetPassword method to change the password.
> >Unfortunately this will not work in production since a password policy with a minimum password length
> >is in force. It is not possible to create an Active Directory user with a blank password.
>
> Steps:
>
> 1) Create the user with the "ADS_UF_PASSWD_NOTREQD" flag (password not
> required) being set to the "userAccountControl" flag of the user
> object. This *should* work even in your production environment.
>
> 2) Then set the user's password to match the minimum length and
> complexity requirements (.SetPassword)
>
> 3) Then update the user object again, to enable it (remove the
> ADS_UF_ACCOUNTDISABLE flag), and to require a password for it (remove
> the ADS_UF_PASSWD_NOTREQD flag).
>
> Now you should have a user account, freshly created, enabled, and with
> a password.
>
> Marc
>
> ________________________________________________________________
> Marc Scheuner ** mscheuner -at- mvps.org ** http://adsi.mvps.org
> Microsoft MVP for Directory Services Programming
> http://www.dirteam.com/blogs/mscheuner/default.aspx
> Come see http://groups.yahoo.com/group/ADSIANDDirectoryServices/
>