Hi Alex,
Thanks again for the help. However, i am not getting much luck with my account unlock script. I did manage to get the 'Add comptuer to group' project working. This is the code from the source that i am using - you can see that it is quite straightforward. However, when i run the test in Script Componant Wizard it fails with 'Script Error: Type or namespace definition, or end-of-file expected.' CAn you help me shed some light on what i am missing?
using System.DirectoryServices.AccountManagement;
using System;
using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;
namespace DynamicNamespace {
public class DynamicClass {
public System.String DynamicMethod(System.String userDn)
{
// this line creates the authentication context for AD interface
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "OURDOMAIN", "DC=OURDOMAIN,DC=co,DC=uk");
{
try
{
UserPrincipal usr = UserPrincipal.FindByIdentity(ctx, userDn);
if (usr != null)
{
if (usr.IsAccountLockedOut())
usr.UnlockAccount();
return "Account" + userDn + " unlocked.";
}
catch (Exception e)
}
return e.Message;
}
}
}
}
}