473,382 Members | 1,389 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.

change password AD using asp.net

I just want to ask abt communicate with AD using ASP.net. I would want to ask you all to help me correct a problem like this:

This is a code i use to change password on AD

Expand|Select|Wrap|Line Numbers
  1. public bool ChangePasswordAD(string strLogin, string strOldPasswd, string strNewPasswd)
  2.     {
  3.         try
  4.         {   string domainAndUsername = "aloha.com" + @"\" + strLogin;
  5.             DirectoryEntry entry = new DirectoryEntry(ConfigurationManager.AppSettings["LDAPpath"].ToString(), domainAndUsername, strOldPasswd, AuthenticationTypes.Secure);
  6.             DirectorySearcher searcher = new DirectorySearcher(entry);
  7.             searcher.Filter = "(&(objectCategory=person)(objectClass=user)(sAMAccountName=strLogin))";
  8.             SearchResult objResult = searcher.FindOne();
  9.             DirectoryEntry objLoginEntry = (objResult != null) ? objResult.GetDirectoryEntry() : null;
  10.             if (objLoginEntry != null)
  11.             {                    
  12.                 object obj = objLoginEntry.Invoke("ChangePassword", new object[] { strOldPasswd, strNewPasswd });
  13.                 objLoginEntry.CommitChanges();
  14.                 obj = null;
  15.             }
  16.             entry = null;
  17.             searcher = null;
  18.             objResult = null;
  19.             objLoginEntry = null;
  20.         }
  21.         catch (Exception ex)
  22.         {
  23.             return false;
  24.         }
  25.         return true;
  26.     }
  27.  
The problem here is :

- If the Admin creates a user and don't check " User must change password the next logon " then the user from client can change password successfully , and without error
- But if the Admin creates a user and check " User must change password the next logon " then the user can't change password .
I know the error caused by : When "User must change password the next logon" is checked, user have to change it immediately in a sign in window, and use new password to login instead of the old password .
How can I deal with this problem ?
Thanks you.
Dec 17 '09 #1
2 5059
i already read it. But it didn't help.
The problem here is
if i had an DirectoryEntry object , i could easily do eveything such as finding, setting properties, getting properties, and so on..
But when the admin checked that property like that, i cann't login successfully to use DirectoryEntry object.
Dec 18 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Max | last post by:
Hi, What is the best way to change passwords via php? I was first thinking of using the chpasswd function, but even though I added an entry for apache to be able to run chpassword vi visudo,...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
4
by: Srikanth | last post by:
Hi All, Can any one tell me how to change windows user account password by programmatically using C#? I don't have administrator privileges and I want to change my account password by...
2
by: Drew Pawlik | last post by:
I am needing to write an application that will be used every month to automatically run queries on an Oracle database. But the password I need to log in to the database needs to be changed every...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
3
by: Xnet | last post by:
I need to change password of a local user of a W2003, without Active Directory. I need to do it from an application created with VB2005. Thanks!
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
3
by: W C Hull | last post by:
We have a request from Auditing to modify the password an a local workstation administrative account every 90 days. We are developing two programs - a VB6 GUI program that will allow the...
6
by: gavy7210 | last post by:
hello i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk 1.5.. i have a login form(jsp) in which a user logs in,in case he doesnt enter his username and/or password an error...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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.