472,783 Members | 903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

urgent help on Active Directory Authentication from dotnet

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
function exactly as outlined in the below link.

http://msdn.microsoft.com/library/de...SecNetHT02.asp

However, the code is not running. When I try to validate the user as
per the function, the following message is displayed to me."Logon
failure: unknown user name or bad password". Any help would be
appreciated in deciphering this error message.

Now going through the code, I am not understanding
DirectoryEntry entry = new DirectoryEntry( _path,
domainAndUsername,
pwd);

My understanding was in the above constructor, one would be passing a
userid and password that has access rights to the AD. Is it true that
any valid user credentials from AD can be used for this purpose? Or do
I need to assign some special rights to the user, so as to make this
function not give me the wierd error jotted above.
Any help in the above will be highly appreciated.

Best regards,

Varkey

Nov 19 '05 #1
6 2392
Hi Varkey,

Welcome to ASPNET newsgroup.
Regarding on the AD authentication validation question you mentioned, here
are some of my understanding and suggestion:

=============
string domainAndUsername = domain + @"\" + username;
DirectoryEntry entry = new DirectoryEntry( _path,
domainAndUsername,
pwd);

try
{
// Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
==============

As mentioned in the article , the above code use the directoryEntry class's
constructor to supply the username/password want to authenticate. and it is
followed by a
Object obj = entry.NativeObject;

statement which force the supplied account(username/password) be
authenticated against AD. Also, to make sure that the specific user is
authenticated, you can explicitly set the AuthenticationType in the
DirectoryEntry's constructor like:

DirectoryEntry entry = new DirectoryEntry(_path,domain\username, password,
AuthenticationTypes.Secure);

Also, since you mentioned that the error message is

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

that indicate that the account you supplied is not a valid user in the
Active directory space. Have you tried using a valid domain account to see
whether it can pass the query or always get such error info. If you always
get such error info when performing the query through a valid domain user,
I'll suggest you try running the same code in a desktop or console
application or contact your Domain admin to see whether they've blocked any
related read permission for normal user(generally all valid domain user
should have the permission to perform read accessing operation).

In addition, if you meet any further ADSI specific problem, you can post in
the

microsoft.public.adsi and its sub newsgroups.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: va***********@wipro.com
| Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft .public.windows.server.act
ive_directory
| Subject: urgent help on Active Directory Authentication from dotnet
| Date: 20 Oct 2005 20:59:23 -0700
| Organization: http://groups.google.com
| Lines: 33
| Message-ID: <11**********************@g49g2000cwa.googlegroups .com>
| NNTP-Posting-Host: 192.85.50.2
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1129867169 19443 127.0.0.1 (21 Oct 2005
03:59:29 GMT)
| X-Complaints-To: gr**********@google.com
| NNTP-Posting-Date: Fri, 21 Oct 2005 03:59:29 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322),gzip(gfe),gzip(gfe)
| Complaints-To: gr**********@google.com
| Injection-Info: g49g2000cwa.googlegroups.com; posting-host=192.85.50.2;
| posting-account=h_OJWQ0AAAAMet9J944p1IM9XfLyU1kX
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!news.glorb.com!postnews.google.com!g49g2000c wa.googlegroups.com!not-fo
r-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.windows.server.active_directory:4 0452
microsoft.public.dotnet.framework.aspnet:132938
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| 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
| function exactly as outlined in the below link.
|
|
http://msdn.microsoft.com/library/de...us/dnnetsec/ht
ml/SecNetHT02.asp
|
| However, the code is not running. When I try to validate the user as
| per the function, the following message is displayed to me."Logon
| failure: unknown user name or bad password". Any help would be
| appreciated in deciphering this error message.
|
| Now going through the code, I am not understanding
| DirectoryEntry entry = new DirectoryEntry( _path,
| domainAndUsername,
| pwd);
|
| My understanding was in the above constructor, one would be passing a
| userid and password that has access rights to the AD. Is it true that
| any valid user credentials from AD can be used for this purpose? Or do
| I need to assign some special rights to the user, so as to make this
| function not give me the wierd error jotted above.
|
|
| Any help in the above will be highly appreciated.
|
| Best regards,
|
| Varkey
|
|

Nov 19 '05 #2
As Steve adviced it seems you don't have access to the AD.
But with my experience with Authenticating with AD it seems also that IIS
can't authticate
with AD.
Are you sure you have set:-
<identity impersonate="true" />
in your web.config also make sure you select Anonymous Access checkbox in
IIS .
In short make sure your Web App is set for forms Auth
Hope that helps
Patrick

"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:zS**************@TK2MSFTNGXA01.phx.gbl...
Hi Varkey,

Welcome to ASPNET newsgroup.
Regarding on the AD authentication validation question you mentioned, here
are some of my understanding and suggestion:

=============
string domainAndUsername = domain + @"\" + username;
DirectoryEntry entry = new DirectoryEntry( _path,
domainAndUsername,
pwd);

try
{
// Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
==============

As mentioned in the article , the above code use the directoryEntry class's constructor to supply the username/password want to authenticate. and it is followed by a
Object obj = entry.NativeObject;

statement which force the supplied account(username/password) be
authenticated against AD. Also, to make sure that the specific user is
authenticated, you can explicitly set the AuthenticationType in the
DirectoryEntry's constructor like:

DirectoryEntry entry = new DirectoryEntry(_path,domain\username, password,
AuthenticationTypes.Secure);

Also, since you mentioned that the error message is

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

that indicate that the account you supplied is not a valid user in the
Active directory space. Have you tried using a valid domain account to see
whether it can pass the query or always get such error info. If you always get such error info when performing the query through a valid domain user,
I'll suggest you try running the same code in a desktop or console
application or contact your Domain admin to see whether they've blocked any related read permission for normal user(generally all valid domain user
should have the permission to perform read accessing operation).

In addition, if you meet any further ADSI specific problem, you can post in the

microsoft.public.adsi and its sub newsgroups.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: va***********@wipro.com
| Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft .public.windows.server.act ive_directory
| Subject: urgent help on Active Directory Authentication from dotnet
| Date: 20 Oct 2005 20:59:23 -0700
| Organization: http://groups.google.com
| Lines: 33
| Message-ID: <11**********************@g49g2000cwa.googlegroups .com>
| NNTP-Posting-Host: 192.85.50.2
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1129867169 19443 127.0.0.1 (21 Oct 2005
03:59:29 GMT)
| X-Complaints-To: gr**********@google.com
| NNTP-Posting-Date: Fri, 21 Oct 2005 03:59:29 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; ..NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
| Complaints-To: gr**********@google.com
| Injection-Info: g49g2000cwa.googlegroups.com; posting-host=192.85.50.2;
| posting-account=h_OJWQ0AAAAMet9J944p1IM9XfLyU1kX
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli ne.de!news.glorb.com!postnews.google.com!g49g2000c wa.googlegroups.com!not-fo r-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.windows.server.active_directory:4 0452
microsoft.public.dotnet.framework.aspnet:132938
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| 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
| function exactly as outlined in the below link.
|
|
http://msdn.microsoft.com/library/de...us/dnnetsec/ht ml/SecNetHT02.asp
|
| However, the code is not running. When I try to validate the user as
| per the function, the following message is displayed to me."Logon
| failure: unknown user name or bad password". Any help would be
| appreciated in deciphering this error message.
|
| Now going through the code, I am not understanding
| DirectoryEntry entry = new DirectoryEntry( _path,
| domainAndUsername,
| pwd);
|
| My understanding was in the above constructor, one would be passing a
| userid and password that has access rights to the AD. Is it true that
| any valid user credentials from AD can be used for this purpose? Or do
| I need to assign some special rights to the user, so as to make this
| function not give me the wierd error jotted above.
|
|
| Any help in the above will be highly appreciated.
|
| Best regards,
|
| Varkey
|
|

Nov 19 '05 #3
Dear Patrick and Steven,

After a lot of fights, I have managed to resolve the problem that I had
faced. Thanks a tonne for both your assistance. Actually I was needing
the AD Authentication for a Desktop application only.

The userID and password that I was using was valid. However, the issue
was with the Path string that I have used. I was trying with
"LDAP://CN=....,OU=....,DC=...." as was shown in the example I have
quoted, even while working from a remote machine.

When I realised that I need to append the IP Address/Domainname of the
server also in the path, I hit bullseye & the code suddenly came
alive..

So I have changed the syntax to
"LDAP://xxx.xx.xx.xxx/CN=....,OU=....,DC=...." for the LDAP Path and it
worked...

Thanks once again for both your help... You don't know what a great
help it is to have people knowledgeable respond to our queries and
provide a completely different perspective, and more options to try
out, when one is at one's wits end.

Keep up the good work. :)

Best regards,
Varkey

Nov 19 '05 #4
This error message means what it says. Either the username or the password
was not understood. Note that other logon failures such as account lockout,
password expiration and account disabled will produce the same general
error.

Sometimes people get the format of the user name wrong though. Perhaps that
is your problem. Can you provide a sample of what your strings look like?

Joe K.

<va***********@wipro.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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
function exactly as outlined in the below link.

http://msdn.microsoft.com/library/de...SecNetHT02.asp

However, the code is not running. When I try to validate the user as
per the function, the following message is displayed to me."Logon
failure: unknown user name or bad password". Any help would be
appreciated in deciphering this error message.

Now going through the code, I am not understanding
DirectoryEntry entry = new DirectoryEntry( _path,
domainAndUsername,
pwd);

My understanding was in the above constructor, one would be passing a
userid and password that has access rights to the AD. Is it true that
any valid user credentials from AD can be used for this purpose? Or do
I need to assign some special rights to the user, so as to make this
function not give me the wierd error jotted above.
Any help in the above will be highly appreciated.

Best regards,

Varkey

Nov 19 '05 #5
Hi Varkey,

Thanks for your followup. Really glad that you've finally figured out the
problem. Also, if you meet any further questions in your development,
please feel free to post in MSDN newsgroup. Always Welcome ! :-)

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: va***********@wipro.com
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Re: urgent help on Active Directory Authentication from dotnet
| Date: 21 Oct 2005 08:35:48 -0700
| Organization: http://groups.google.com
| Lines: 29
| Message-ID: <11**********************@g47g2000cwa.googlegroups .com>
| References: <11**********************@g49g2000cwa.googlegroups .com>
| <zS**************@TK2MSFTNGXA01.phx.gbl>
| <ul**************@TK2MSFTNGP14.phx.gbl>
| NNTP-Posting-Host: 205.156.188.254
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1129908953 11021 127.0.0.1 (21 Oct 2005
15:35:53 GMT)
| X-Complaints-To: gr**********@google.com
| NNTP-Posting-Date: Fri, 21 Oct 2005 15:35:53 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET
CLR 1.1.4322),gzip(gfe),gzip(gfe)
| Complaints-To: gr**********@google.com
| Injection-Info: g47g2000cwa.googlegroups.com;
posting-host=205.156.188.254;
| posting-account=h_OJWQ0AAAAMet9J944p1IM9XfLyU1kX
| Path:
TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!nntp.giganews. com!news.glorb.com!postnew
s.google.com!g47g2000cwa.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:133042
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Dear Patrick and Steven,
|
| After a lot of fights, I have managed to resolve the problem that I had
| faced. Thanks a tonne for both your assistance. Actually I was needing
| the AD Authentication for a Desktop application only.
|
| The userID and password that I was using was valid. However, the issue
| was with the Path string that I have used. I was trying with
| "LDAP://CN=....,OU=....,DC=...." as was shown in the example I have
| quoted, even while working from a remote machine.
|
| When I realised that I need to append the IP Address/Domainname of the
| server also in the path, I hit bullseye & the code suddenly came
| alive..
|
| So I have changed the syntax to
| "LDAP://xxx.xx.xx.xxx/CN=....,OU=....,DC=...." for the LDAP Path and it
| worked...
|
| Thanks once again for both your help... You don't know what a great
| help it is to have people knowledgeable respond to our queries and
| provide a completely different perspective, and more options to try
| out, when one is at one's wits end.
|
| Keep up the good work. :)
|
| Best regards,
| Varkey
|
|

Nov 19 '05 #6
No worries varkey.
You are welcome.
Patrick
"va***********@wipro.com" wrote:
Dear Patrick and Steven,

After a lot of fights, I have managed to resolve the problem that I had
faced. Thanks a tonne for both your assistance. Actually I was needing
the AD Authentication for a Desktop application only.

The userID and password that I was using was valid. However, the issue
was with the Path string that I have used. I was trying with
"LDAP://CN=....,OU=....,DC=...." as was shown in the example I have
quoted, even while working from a remote machine.

When I realised that I need to append the IP Address/Domainname of the
server also in the path, I hit bullseye & the code suddenly came
alive..

So I have changed the syntax to
"LDAP://xxx.xx.xx.xxx/CN=....,OU=....,DC=...." for the LDAP Path and it
worked...

Thanks once again for both your help... You don't know what a great
help it is to have people knowledgeable respond to our queries and
provide a completely different perspective, and more options to try
out, when one is at one's wits end.

Keep up the good work. :)

Best regards,
Varkey

Nov 19 '05 #7

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

Similar topics

2
by: Jay Chan | last post by:
We have just installed a SQL Server 2000 (SP 3A) onto a computer that has Windows-2003 Server on it. Now, we cannot get access to that database server from other computers. Seem like this may be an...
1
by: techfuzz | last post by:
I'm posting my problem experience and solution I found here for other ASP.NET developers. I have a web application that uses Forms Authentication with Active Directory to control access. In...
3
by: Chris L | last post by:
Hello, I'm hoping to find out if it is possible to connect within an ASP.NET application to Active Directory with the credentials of the person who accessed the ASP.NET application via IIS,...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
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...
2
by: Tdar | last post by:
Sorry for the dup post but looking for a response and this is being posted under my MSDN managed newsgroups handle and in a different newsgroup Hi, As I said in the past post I am using this...
2
by: MJ | last post by:
Hi, I'm trying to authenticate a user by creating a DirectoryEntry using the contructor with signature Dim objEntry = New DirectoryEntry(path, username, pwd). and then i check for If Not...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Bren | last post by:
Hi All My appologies for the URGENT shout but I need to get this sorted by 06:00 GMT otherwise I am going to have 150 screaming intranet users moaning at me. Win 2k Server ASP.NET 2 I have...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.