473,385 Members | 1,610 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,385 software developers and data experts.

Active Directory Authentication - password reset not working correctly PLEASE HELP!

Hello,

I have been scanning the internet for a few days now. That is not working. So now it is time to post!

I have read a few other posts on here about authentication but they do not match exactly.

We currently have an intranet app built in a mixture of asp and asp.net 1.1 and 2.0 written in VB .Net. We have a form where the user logs in and it authenticates against active directory successully in 2 ways:

1. The admin resets the password and the user logs in using that password (not forced to change)

2. The user changes their password themselves.


HOWEVER

When the admin resets the password and checks the box to "force the password change" the application does not work. Here is the code that is causing the problem (specifically the DirectoryEntry, that is where the code fails). I have walked through the debugger and the code works fine for the 2 conditions I described above, but returns a the following error message when the password is reset and the user is "forced" to change their password:

{"Logon failure: unknown user name or bad password."}

Expand|Select|Wrap|Line Numbers
  1. Public Function IsAuthenticated(ByVal strUserId As String, _
  2.                                         ByVal strPassword As String) As Boolean
  3.  
  4.             Dim strDomainAndUsername As String = strDomain & "\" & strUserId
  5.             entry = New DirectoryEntry(adPath, strDomainAndUsername, strPassword, AuthenticationTypes.Secure)
  6.  
  7.             Try
  8.                 Dim search As DirectorySearcher = New DirectorySearcher(entry)
  9.  
  10.                 search.Filter = "(SAMAccountName=" & strUserId & ")"
  11.                 search.PropertiesToLoad.Add("cn")
  12.                 Dim result As SearchResult = search.FindOne()
  13.  
  14.                 If (result Is Nothing) Then
  15.                     Return False
  16.                 End If
  17.  
  18.             Catch ex As Exception
  19.                 Throw New Exception("Error authenticating user. " & ex.Message)
  20.             End Try
  21.  
  22.             Return True
  23.         End Function
  24.  
Please, any help with this would be greatly appreciated. It is a requirment of my company to force the password change after a user's password is reset. Not complying could mean big problems.



Thanks for your time,

Joe


Also, if there is any documentation that explains this better please let me know. What I have learned about Active Directory and authentication has been random posts and articles on the internet over the past few days.
Mar 20 '07 #1
6 9885
kenobewan
4,871 Expert 4TB
Welcome to the site. I believe that either the admin account is locked or the credentials are incorrect. I have paid the price recently for not having a test admin account, as failed tests were locking the live admin account :|.

I'd suggest getting a book or doing a course - I agree resources for AD on the net aren't great. HTH.
Mar 21 '07 #2
Thanks a million for replying! I have been monitoring this thread like a hawk!


Not sure I understand you response.

What admin account is locked.


Right now this is how it works. Admins on my team get requests from users to reset their passwords. They then login and reset the user's password via a tool called URMA(home grown tool).

The user will then try to login as normal. When a user logs in the code above gets executed. Specifically this line:

Expand|Select|Wrap|Line Numbers
  1. entry = New DirectoryEntry(adPath, strDomainAndUsername, strPassword, AuthenticationTypes.Secure) 
When the admin resets a users password and does not force them to change their password (does not check the checkbox in the tool), the user can login fine and the line of code above does not have any problems.

HOWEVER

If the admin checks the box to "force a password change" the line of code above fails with :

{"Logon failure: unknown user name or bad password."}

The DirectoryEntry initialization is not performing any admin modifications at this point. I beleive it is merely validating that the user and password are valid.



We have noticed one thing that could possibly be causing this. When the admin resets the password WITHOUT "forcing the user to change password" the value of the property pwdLastSet contains an actual date.

When the admin "forces a password change" the pwdLastSet value is null or "no value set". Could this be the culprit?

I only suspect this because out of the many posts I have looked at, when a developer wants to force a user to change their password within the code they are doing something like this:

Expand|Select|Wrap|Line Numbers
  1. user.Put("pwdLastSet", 0)
  2.  

So, now that I am on a tangent would the fact that there is no value set in pwdLastSet for a user be causing the DirectoryEntry initialization to fail with the
error:
{"Logon failure: unknown user name or bad password."}

???


Thanks again,

Joe
Mar 21 '07 #3
kenobewan
4,871 Expert 4TB
Hi Joe,

Obviously, I've never used your URMA tool but assume that it is a .NET application and works similarly to the AD applications that I work with. We have been going through a .NET 2 upgrade and I had to test our applications with new LDAP strings. I got locked out a couple of times as a consequence (same error message).

My suggestion is to get your Active Directory admin to check the account(s) used by your local admins who use the tool. In the tool, there are I assume different scripts being called depending on whether the checkbox is checked or not. Whether they use different connection strings or different credentials or the account is locked, I believe that this is where the problem lies. HTH.
Mar 22 '07 #4
Well that would make sense.

What doesn't make sense though, is that we can login through our citirx web interface and it works correctly. By this I mean that when the admin forces the change in our URMA tool, the user can login through citrix and it immedietly directs them to change their password like it should.

So this would point back to the code I am working with...
Mar 27 '07 #5
kenobewan
4,871 Expert 4TB
Your LDAP connection using AuthenticationTypes is .NET 2. The problem appears to be a schema caching problem, which is a fancy way of saying if your login fails it falls back to anonymous connection with only LDAP version 2 available. I would predict that this means that you can still connect, as you have discovered, but certain fields e.g. samaccountname may write as system.byte[].

Please follow these steps:
1. Have the admin accounts checked to see if they are locked.
2. Have the admin accounts credentials checked.

I wasted time playing with the code when I had a problem. Lets rule out the problem I am referring to. Thanks.
Mar 28 '07 #6
kenobewan
4,871 Expert 4TB
BTW - reread your posts to check that I am not missing anything. If pwdLastSet was null I would expect a null exception error when the admin tried to force the change. You are right that it is strange that it is working in citrix, that I can't explain :(.
Mar 28 '07 #7

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

Similar topics

3
by: CLEAR-RCIC | last post by:
Hi. I have some code that updates a user's account properties in Active Directory. The code also has a call that resets the account password (see code below). I put the code in a .dll and have a...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
7
by: - Steve - | last post by:
I have forms based authentication working, using my Active Directory for authentication. I have a web page that creates a user in active directory. When I was using IIS authentication it worked...
9
by: Patrick | last post by:
I have an ASP.NET page that searches for someone in the corporate Active Directory. It had been working fine until recently when I changed from Basic Authentication on IIS6 back to Integrated...
6
by: varkey.mathew | last post by:
Dear all, Bear with me, a poor newbie(atleast in AD).. I have to authenticate a user ID and password for a user as a valid Active Directory user or not. I have created the IsAuthenticated...
10
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to...
2
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
5
by: wak0 | last post by:
Hi, I hope you guys can help me. I need to build a form that request username and password on ASP not ASP.net (sorry to clarify but i got some responses in other forums in .net) This form will...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.