473,756 Members | 9,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory LDAP Authentication Fails in IIS 6

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 because all we do is
verify the user on the login form so we can redirect them to the appropriate
page based on their group.
The code to authenticate is:
Public Function IsAuthenticated (ByVal domain As String, ByVal username As
String, ByVal pwd As String) As Boolean
Dim domainAndUserna me As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry( _path,
domainAndUserna me, pwd)
Try
'Bind to the native AdsObject to force authentication.
Dim obj As Object = entry.NativeObj ect
Dim search As DirectorySearch er = New DirectorySearch er(entry)
search.Filter = "(SAMAccountNam e=" & username & ")"
search.Properti esToLoad.Add("c n")
Dim result As SearchResult = search.FindOne( )
If (result Is Nothing) Then
Return False
End If
'Update the new path to the user in the directory.
_path = result.Path
_filterAttribut e = CType(result.Pr operties("cn")( 0), String)
Catch ex As Exception
Throw New Exception("Erro r authenticating user. " & ex.Message &
"<BR>" & ex.StackTrace.T oString)
End Try
Return True
End Function

In IIS 6, we have tried all possible combinations of directory security.

When we first moved the site to IIS 6, an error was generated by the above
code stating the parameter was incorrect, so we tried adding
AuthenticationT ypes.None and AuthenticationT ypes.Anonymous as the final
parameter for DirectoryEntry( ... The result was a message returned as
"unknown user name or bad password. The user name and password entered were
correct, so I don't understand why that error was generated.

Any ideas would be greatly appreciated.

Paul
Mar 24 '06 #1
2 4697
Paul,
It seems you can't Authenticate using the Active Directory thats why you are
getting:
"unknown user name or bad password.
Is the server in the same domain of the Active Directory and again.
Are you sure the IIS can authenticate on the domain?
Is integrated Windows Auth checked in the IIS ?
Patrick
"P Webster" <NO************ ******@ix.netco m.com> wrote in message
news:ep******** ******@TK2MSFTN GP12.phx.gbl...
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 because all we do is
verify the user on the login form so we can redirect them to the
appropriate page based on their group.
The code to authenticate is:
Public Function IsAuthenticated (ByVal domain As String, ByVal username As
String, ByVal pwd As String) As Boolean
Dim domainAndUserna me As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry( _path,
domainAndUserna me, pwd)
Try
'Bind to the native AdsObject to force authentication.
Dim obj As Object = entry.NativeObj ect
Dim search As DirectorySearch er = New DirectorySearch er(entry)
search.Filter = "(SAMAccountNam e=" & username & ")"
search.Properti esToLoad.Add("c n")
Dim result As SearchResult = search.FindOne( )
If (result Is Nothing) Then
Return False
End If
'Update the new path to the user in the directory.
_path = result.Path
_filterAttribut e = CType(result.Pr operties("cn")( 0), String)
Catch ex As Exception
Throw New Exception("Erro r authenticating user. " & ex.Message &
"<BR>" & ex.StackTrace.T oString)
End Try
Return True
End Function

In IIS 6, we have tried all possible combinations of directory security.

When we first moved the site to IIS 6, an error was generated by the above
code stating the parameter was incorrect, so we tried adding
AuthenticationT ypes.None and AuthenticationT ypes.Anonymous as the final
parameter for DirectoryEntry( ... The result was a message returned as
"unknown user name or bad password. The user name and password entered
were correct, so I don't understand why that error was generated.

Any ideas would be greatly appreciated.

Paul

Mar 25 '06 #2
Patrick,
Thanks for the reply.
I actually cross-posted this message in ...aspnet.secur ity and received very
good help from Joe Kaplan.
It turns out we were struggling with this problem in the wrong way. The
original code that worked on the W2K server with IIS 5.1 had a bad
parameter, and it probably shouldn't have been working in the first place.
Here is the final post I made in the other group just in case this problem
happens to someone else.

The DirectoryEntry parameters being sent (and I might mention successfully
in IIS 5.1) were:
entry = New DirectoryEntry( "LDAP://biz.xxx.yyy.com/DC=biz, DC=xxx, DC=yyy,
DC=com", "DC=biz\usernam e", "password")
For some reason, the domain\username included "DC=" in front of it and IIS
5.1 must have dropped that off when trying to authenticate the user. When
we removed the "DC=" and just used "biz\userna me", everything worked as
expected.

We didn't figure it out until we decided to write a test application in
ASP.NET 2.0. When everything worked correctly, we started from scratch and
wrote the entire process in ASP.NET 1.1 without reviewing the existing code.
When it worked, we compared the two and found the mistake. When we found
the sample code used to originally write the AD Authenticatio a couple of
years ago, it included the "DC=" before the user name. Since it has always
functioned properly, we never looked there. We kind of feel stupid now :)

"Patrick.O. Ige" <na********@hot mail.com> wrote in message
news:eR******** ******@TK2MSFTN GP11.phx.gbl...
Paul,
It seems you can't Authenticate using the Active Directory thats why you
are getting:
"unknown user name or bad password.
Is the server in the same domain of the Active Directory and again.
Are you sure the IIS can authenticate on the domain?
Is integrated Windows Auth checked in the IIS ?
Patrick
"P Webster" <NO************ ******@ix.netco m.com> wrote in message
news:ep******** ******@TK2MSFTN GP12.phx.gbl...
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 because all we do is
verify the user on the login form so we can redirect them to the
appropriate page based on their group.
The code to authenticate is:
Public Function IsAuthenticated (ByVal domain As String, ByVal username As
String, ByVal pwd As String) As Boolean
Dim domainAndUserna me As String = domain & "\" & username
Dim entry As DirectoryEntry = New DirectoryEntry( _path,
domainAndUserna me, pwd)
Try
'Bind to the native AdsObject to force authentication.
Dim obj As Object = entry.NativeObj ect
Dim search As DirectorySearch er = New DirectorySearch er(entry)
search.Filter = "(SAMAccountNam e=" & username & ")"
search.Properti esToLoad.Add("c n")
Dim result As SearchResult = search.FindOne( )
If (result Is Nothing) Then
Return False
End If
'Update the new path to the user in the directory.
_path = result.Path
_filterAttribut e = CType(result.Pr operties("cn")( 0), String)
Catch ex As Exception
Throw New Exception("Erro r authenticating user. " & ex.Message &
"<BR>" & ex.StackTrace.T oString)
End Try
Return True
End Function

In IIS 6, we have tried all possible combinations of directory security.

When we first moved the site to IIS 6, an error was generated by the
above code stating the parameter was incorrect, so we tried adding
AuthenticationT ypes.None and AuthenticationT ypes.Anonymous as the final
parameter for DirectoryEntry( ... The result was a message returned as
"unknown user name or bad password. The user name and password entered
were correct, so I don't understand why that error was generated.

Any ideas would be greatly appreciated.

Paul


Mar 25 '06 #3

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

Similar topics

3
3133
by: Marc Eggenberger | last post by:
Hi there. I have the following environment: Active Directory running on Windows 2000. There is a root domain called ad.sys and within this root domain there are the following subdomains: dom1.ad.sys dom2.ad.sys dom3.ad.sys
1
4755
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
9
3179
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 Windows authentication. The error occurs on the FindAll method. The exceptions are as follows. anyway of getting the code working with Integrated Windows authentication (too annoying for user to enter user-name/password). Note I do need to use...
10
4064
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 Pop up windows Authentication box so that user will give his userId, Password & domain name for authenticaion. After that I want to take these three info of user and make a search in Active Directory.
3
2053
by: Susan | last post by:
Hello all, My ASP.NET application seems to have intermittent problems when connecting to Active Directory server. Most of the time the Active Directory app works fine then suddenly fails and will repeatedly occur for a period of time then start working fine again. ASP.NET application uses windows authentication. I am attaching the code for reference: -----------------------------
18
23792
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 code/examples? Thanks in advance, Arthur
18
3414
by: troywalker | last post by:
I am new to LDAP and Directory Services, and I have a project that requires me to authenticate users against a Sun Java System Directory Server in order to access the application. I have found dozens of examples of how to authenticate users against Active Directory, but AD seems to be a different animal than Sun Java System Directory Server. Could someone provide me with an example of how to authenticate a user against a Directory...
7
14241
by: =?Utf-8?B?TWlrZQ==?= | last post by:
I'm trying to use the DirectorySearcher.FindOne() method to get the display name of the current user. The code runs on a server behind a web service. Everything works fine when I run it on my local machine but the FindOne() method fails when I deploy it to the server. I'm at a loss and any help would be appreciated. This is the code that works on my local machine but not on the server. DirectorySearcher search = new...
5
5492
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 send an LDAP query into the active directory located on a different server and it will check for existing users. If the users exist they will be redirected to a new page. if not they will be prompt to try again for username and password. What...
0
9482
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9292
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10062
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9728
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8733
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7282
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6551
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.