Re: Programming the User-Account_Property using C#
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Fri, 9 Mar 2007 17:52:17 +0100
"Chris Noble" <chris.noble@xxxxxxxxxxxxxxxx> wrote in message news:ulIV3QmYHHA.3268@xxxxxxxxxxxxxxxxxxxxxxx
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
The only way to set this "user cannot change password" property is by turning the ACE's on the user object into an ACCESS_DENIED_ACE type ACE.
This can be done by using the DirectorySecurity class of the System.Security.AccessControl namespace.
Willy.
.
- Follow-Ups:
- Re: Programming the User-Account_Property using C#
- From: Chris Noble
- Re: Programming the User-Account_Property using C#
- References:
- Programming the User-Account_Property using C#
- From: Chris Noble
- Programming the User-Account_Property using C#
- Prev by Date: Re: ref vs. out: same at runtime, same/different at compiler time?
- Next by Date: Re: DLL Import method
- Previous by thread: Programming the User-Account_Property using C#
- Next by thread: Re: Programming the User-Account_Property using C#
- Index(es):
Relevant Pages
|