Hola!! Estoy haciendo una aplicacion en C# para dar de altas a usuarios en el
directorio activo, pero al intentar crear el usuario me da un error al poner
la contraseña. Mi codigo es el siguiente:
try
{
DirectoryEntry objDE;
StringstrPath="LDAP://OU=Admins,OU=acctZonaCanarias..";
if(args.Length>0)strPath=args[1];
// Create a new DirectoryEntry with the given path.
objDE=new DirectoryEntry(strPath);
DirectoryEntries objChildDE = objDE.Children;
DirectoryEntry myDirectoryEntry = objChildDE.Add("CN=prueba6", "user");
myDirectoryEntry.Properties["userPrincipalName"].Value = "prueba6";
myDirectoryEntry.Properties["name"].Value = "prueba6";
// myDirectoryEntry.Invoke("SetPassword", new object[] {"Pwd-appprueba6"});
// myDirectoryEntry.Properties["PasswordRequired"].Value = 1;
myDirectoryEntry.Properties["samAccountName"].Value = "prueba6";
myDirectoryEntry.Properties["description"].Value = "Descripcion del
Usuario";
//myDirectoryEntry.Properties["AccountDisabled"].Value = 1;
myDirectoryEntry.Properties["pwdLastSet"].Value = -1;
myDirectoryEntry.CommitChanges();
myDirectoryEntry.Dispose();
MessageBox.Show("Worked!!");
}
catch (Exception ex)
{
MessageBox.Show("error");
}
}
Asi me funciona y crea el usuario, pero poniendo las lineas que estan
comentadas me da un error.
¿Que puede ser?
Gracias
Leer las respuestas