Programming the User-Account_Property using C#
- From: "Chris Noble" <chris.noble@xxxxxxxxxxxxxxxx>
- Date: Fri, 9 Mar 2007 16:01:34 -0000
I am not sure that I have picked the right newsgroup for this post.
I am writing a program in C# VS 2005 to create user accounts for our
students in Active Directory.
This is to replace a program I wrote some years ago in VS6 using C++ and
ADSI.
I am trying not to use ADSI in my new program, focussing on
DirectoryServices instead.
In C# the syntax to set an Active Directory property is something like:
entry.Properties["givenName"].value="Jim"; (where entry is a
DirectoryEntry)
However for the userAccountControl property it is necessary to use a
combination of enumerated identifiers.
see http://msdn2.microsoft.com/en-us/library/aa772300.aspx
I do not want the students to be able to change a password so I need to use
ADS_UF_PASSWD_CANT_CHANGE.
This flag can be read, but not set directly as it involves setting trustee
rights etc. There is a link to an example program to set this flag but it is
in C++ and uses ADSI which I want to avoid.
Surely there must be a nice new clean way of doing this in Framework 2.0.
Is there any example C# code using DirectoryServices to set
ADS_UF_PASSWD_CANT_CHANGE?
I don't want to have to write a wrapper for my existing unmanaged code which
involved ACEs, ACLs, security descriptors etc
.
- Follow-Ups:
- Re: Programming the User-Account_Property using C#
- From: Willy Denoyette [MVP]
- Re: Programming the User-Account_Property using C#
- Prev by Date: Re: Images in datagrid!
- Next by Date: Re: how to send NULL to database?
- Previous by thread: How to find a particular program is running or not?
- Next by thread: Re: Programming the User-Account_Property using C#
- Index(es):
Loading