views:

615

answers:

5

I'd like to write a .net program to update active directory data in an existing field, or extend the schema to add a new field.

Does anyone know the best way to go about this?

A: 

you are looking for the namespace and dll System.DirectoryServices.

The actual usage of this Namespace is fairly complex and you aren't indicating if you need specific help with it so I will leave it at that.

I have always done the field extending using System tools and haven't done any programmatic change to fields.

Jeff Martin
A: 

Try using PowerShell to modify Active Directory. Here's an introduction: http://technet.microsoft.com/en-us/magazine/2007.06.powershell.aspx.

Eric H
A: 

For editing data, I've used System.DirectoryServices in the past. Haven't done extending of fields.

Eugene Katz
A: 

You may also want to look into ADAM (Active Directory Application Mode). I have used this as a development environment and it was fairly successful.

Jeff Martin
+3  A: 

To update a field, you new up a DirectoryEntry for the object you want to update, set the property (look in the Properties collection) to its new value, then call CommitChanges() to save the changes for good. And watch out for multi-valued properties.

I don't know if I would recommend extending the schema programmatically though. I'd rather play it safe and have the IT admins use the Active Directory Schema MMC snap-in or ldifde instead. Anyhow, Microsoft has a sample on schema programming here And if you must, you should practice with ADAM no matter whichever way you go.

IMHO, this is the definitive book on AD programming using .NET: The .NET Developer's Guide to Directory Services Programming

barneytron