473,382 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ADSI - Creating an AD account but not forcing a "change password on first login"

Having a heck of a time trying to create a ton of AD user accounts in a specific
OU without having the users be forced to change their password upon a successful
login.

After creating the account (and committing the changes), I have the following
code that works:
// password info
userEntry.Invoke("SetPassword", new object[]{this.m_defaultPassword});
userEntry.Properties["pwdLastSet"].Value = 0;
userEntry.Properties["userAccountControl"].Value = 0x200; //ADS_UF_DONT_EXPIRE_PASSWD
userEntry.CommitChanges();

I've tried setting a value for the "pwdLastSet" property, and also trying
a few different combinations for the "userAccountControl" integer bitmap,
but no luck (either throwing exceptions or just not desireable results.

After searching various groups for solutions (managed or scripted), I'm still
at a loss, hence this posting. Any tips/pointers would be greatly appreciated.

--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
Feb 8 '06 #1
2 2610
>After creating the account (and committing the changes), I have the following
code that works:
// password info
userEntry.Invoke("SetPassword", new object[]{this.m_defaultPassword});
userEntry.Properties["pwdLastSet"].Value = 0;
userEntry.Properties["userAccountControl"].Value = 0x200; //ADS_UF_DONT_EXPIRE_PASSWD
userEntry.CommitChanges();


You just got the ADS_UF_DONT_EXPIRE_PASSWD wrong - that's all ;-)

0x0200 is "normal account"
0x2000 is "don't expire password"

and combined it would be 0x2200

Try setting it to that value - it ought to work if you do!;-)

HTH
Marc
Feb 8 '06 #2
Thanks for the reply Mark, unfortunately it didn't work, however you got
me in the right direction.

The hex you need to assign to the "userAccountControl" property is 0x220,
not 0x2200 (that was throwing a COMException). I also had to remove the line
containing the "pwdLastSet" property.

Thanks!

--
-AC [MVP MCMS]
http://www.andrewconnell.com
http://www.andrewconnell.com/mvp
After creating the account (and committing the changes), I have the
following
code that works:
// password info
userEntry.Invoke("SetPassword", new
object[]{this.m_defaultPassword});
userEntry.Properties["pwdLastSet"].Value = 0;
userEntry.Properties["userAccountControl"].Value = 0x200;
//ADS_UF_DONT_EXPIRE_PASSWD
userEntry.CommitChanges();

You just got the ADS_UF_DONT_EXPIRE_PASSWD wrong - that's all ;-)

0x0200 is "normal account"
0x2000 is "don't expire password"
and combined it would be 0x2200

Try setting it to that value - it ought to work if you do!;-)

HTH
Marc

Feb 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nestor Vives | last post by:
const int UF_DONT_EXPIRE_PASSWD =0x10000; user.Properties.Add(UF_DONT_EXPIRE_PASSWD); The code above CHECKS the "Password Never Expires" option for a NT/AD user How do I programmatically...
1
by: Ezra | last post by:
Our company's web server is trying to access graphics files on another server. When I run the app from Visual Studio (1.0) on my localhost, the server in question is available (which is accessed a...
8
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
2
by: Ofer | last post by:
Hi, We use the ASP.net loginControls and the DB schema. How to programmatically activate the "PasswordRecovery" of a specific end-user when a user clicks my web application's button? I need to...
0
by: FrankieBakerJr | last post by:
Hello all I have an ASP.NET 2003 application (running Windows XP) that allows user to change and reset their Active Directory password. I'm using an admin account to query and reset the passwords...
3
by: =?Utf-8?B?QXhlbCBEYWhtZW4=?= | last post by:
Hi, we've got a strange problem here: We've created an ASP.NET 2.0 web application using Membership.ValidateUser() to manually authenticate users with our website. The problem is: If the...
3
by: groupie | last post by:
Hi, I'd like to know how to implement the "Forgot Password" feature on many websites which require a login, exactly like this ebay example:...
1
by: groupie | last post by:
Hi, I'd like to know how to implement the "Forgot Password" feature on many websites which require a login, exactly like this ebay example:...
6
by: lightyagami | last post by:
how to code the "forgot your password?" in php??? i have a login account where i want to display also the "forgot your password?" but i dont know how to code it in PHP...can u help me?
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.