Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2007

Tip: Looking for answers? Try searching our database.

Update AD with VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jimstruckster@gmail.com - 20 Sep 2007 15:31 GMT
Hey everyone,
    I'm working on a project to set up a new user in AD using VB.  I
have the connection working and I'm able to get most of the settings
done.  However I can't find the properties to set the password to
never expire and the user cannot change password.  I'd also like to be
able to set the logon hours as well.  If someone can help me out with
those properties in VB I would appreciate it.  Thanks a lot!
Jani Järvinen [MVP] - 21 Sep 2007 15:05 GMT
Hi there,

> However I can't find the properties to set the password to
> never expire and the user cannot change password.

I don't have ready-made VB.NET code for you, but here are some examples
using native Visual Basic:

http://msdn2.microsoft.com/en-us/library/aa705921.aspx

If you can get the property "userAccountControl" of your user object, then
you should be able to change the settings you are after. The value is a flag
value, and here are (in C#) the possible flag values:

public enum ADS_UF_ENUM
{
ADS_UF_SCRIPT = 0X0001,
ADS_UF_ACCOUNTDISABLE = 0X0002,
ADS_UF_HOMEDIR_REQUIRED = 0X0008,
ADS_UF_LOCKOUT = 0X0010,
ADS_UF_PASSWD_NOTREQD = 0X0020,
ADS_UF_PASSWD_CANT_CHANGE = 0X0040,
ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = 0X0080,
ADS_UF_TEMP_DUPLICATE_ACCOUNT = 0X0100,
ADS_UF_NORMAL_ACCOUNT = 0X0200,
ADS_UF_INTERDOMAIN_TRUST_ACCOUNT = 0X0800,
ADS_UF_WORKSTATION_TRUST_ACCOUNT = 0X1000,
ADS_UF_SERVER_TRUST_ACCOUNT = 0X2000,
ADS_UF_DONT_EXPIRE_PASSWD = 0X10000,
ADS_UF_MNS_LOGON_ACCOUNT = 0X20000,
ADS_UF_SMARTCARD_REQUIRED = 0X40000,
ADS_UF_TRUSTED_FOR_DELEGATION = 0X80000,
ADS_UF_NOT_DELEGATED = 0X100000,
ADS_UF_USE_DES_KEY_ONLY = 0x200000,
ADS_UF_DONT_REQUIRE_PREAUTH = 0x400000,
ADS_UF_PASSWORD_EXPIRED = 0x800000,
ADS_UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION = 0x1000000
};

From these flags, the values ADS_UF_PASSWD_CANT_CHANGE and
ADS_UF_DONT_EXPIRE_PASSWD should be the ones you need. Haven't tested,
though.

Hope this helps!

Signature

Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
janij@removethis.dystopia.fi
http://www.saunalahti.fi/janij/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.