System.DirectoryServices help

  • Thread starter Tim Mitchell via .NET 247
  • Start date
T

Tim Mitchell via .NET 247

Hey everyone,

I'm an experienced C# coder but I'm working with theSystem.DirectoryServices namespace for the first time. I'm alsonot yet a pro at Active Directory, so I have a bit of ahandicap. Nonetheless, I'm trying to create a simple Windowsapplication that will allow an authorized user to do thefollowing:

-- Create a new Active Directory account using a preexistingaccount as a template
-- Specify the user name and given name, and set the password
-- Map the user's "My Documents" to an individual folder (thisfolder will already exist)

Also, as a way of maintenance, authorized users will need to beable to:
-- Reset passwords for existing users
-- Disable or delete existing user accounts

So far, I've found a little information about directory services,but most of it assumes that the programmer is an expert atmanipulating Active Directory objects. Could anyone give somesimple and straightforward C# code samples that can lead me inthe right direction to complete this task? Or, if adocument/book/tutorial already exists that covers this subjectthoroughly, please let me know where to find it?

Thanks in advance...
Tim
 
M

Marc Scheuner [MVP ADSI]

I'm an experienced C# coder but I'm working with the System.DirectoryServices namespace for the first time.
I'm also not yet a pro at Active Directory, so I have a bit of a handicap.

In general, you'd get better and more answers in the specific Active
Directory newsgroups, such as microsoft.public.adsi.general. That's
where all the AD gurus hang out
-- Create a new Active Directory account using a preexisting account as a template

So you know how to basically create a user?? Bind to the container
it's supposed to be in, create it, set some properties, commit the
changes back to the AD store?

Now, secondly - there's no such feature as creating a new user based
on an existing template, unfortunately. You'd have to roll your own.

Basically, if you have a "template" user somewhere in your AD
hierarchy, you could create your new user as mentioned above, and then
go about these steps:

* additionally, bind to the template user
* start setting properties on your newly created user by reading out
the corresponding values from your template user

This would achieve the same result in the end - a new user, which has
the same properties as some specific template user you define
somewhere.
-- Specify the user name and given name,

There are a GREAT many user "names" that can be specified - which one
do you mean??

* cn/name : the user object actual name, e.g. it's name in the
directory. Preferably very simple, e.g. no special chars like slashes,
backslashes, and so forth. Keep it short and sweet

* givenName : first name of the user
* sn: surname / last name of the user
* displayName: also often referred to as the "Full Name" - set it to
whatever you like. This is the attribute most admin tools *should*
display by default (most however choose to show you the "cn" value
instead)
-- Map the user's "My Documents" to an individual folder (this folder will already exist)

You can do this by setting the user's "HomeDrive" and "HomeDirectory"
attributes.

Also, you might want to download my free BeaverTail ADSI browser to
roam around your AD hierarchy and see what the user objects'
properties are called and what they are set to.

Go grab it from:
http://adsi.mvps.org/adsi/CSharp/beavertail.html

Cheers!
Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top