AD Authentication in ASP.NET

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to implement active directory authentication but I am getting exception which is like <br/>
<br/>
System.Runtime.InteropServices.COMException was caught<br/>
Message=Unknown error (0x80005000)<br/>
Source=System.DirectoryServices<br/>
ErrorCode=-2147463168<br/>
StackTrace:<br/>
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)<br/>
at System.DirectoryServices.DirectoryEntry.Bind()<br/>
at System.DirectoryServices.DirectoryEntry.get_AdsObject()<br/>
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)<br/>
at System.DirectoryServices.DirectorySearcher.FindOne()<br/>
at ConsoleApplication1.ADAuthentication.AuthenticateADUsers(String userNameWithDomain, String password) in C:Usersawadhendratdocumentsvisual studio 2010ProjectsConsoleApplication1ConsoleApplication1Program.cs:line
83<br/>
at ConsoleApplication1.Program.Main(String[] args) in C:Usersawadhendratdocumentsvisual studio 2010ProjectsConsoleApplication1ConsoleApplication1Program.cs:line 23<br/>
InnerException: <br/>
<br/>
I dont know what I am missing. Following code I have written for implementing AD Authentication.<br/>
<br/>
public bool AuthenticateADUsers(string userNameWithDomain, string password)<br/>
{<br/>
DirectoryEntry objDirectoryEntry = null;<br/>
DirectorySearcher objDirectorySearcher = null;<br/>
<br/>
try<br/>
{<br/>
objDirectoryEntry = new DirectoryEntry("https://ab.hotels.com/", userNameWithDomain, password, AuthenticationTypes.Delegation);<br/>
objDirectorySearcher = new DirectorySearcher(objDirectoryEntry);<br/>
objDirectorySearcher.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (sAMAccountName={0}))", userNameWithDomain.Substring(0, userNameWithDomain.IndexOf(@)));<br/>
objDirectorySearcher.PropertiesToLoad.Add("msRTCSIP-PrimaryUserAddress");<br/>
var result = objDirectorySearcher.FindOne();<br/>
if (result != null)<br/>
return true;<br/>
else<br/>
return false; <br/>
}<br/>
catch<br/>
{<br/>
throw;<br/>
}<br/>
}<br/>
<br/>
I have done some google but not getting helpful. Here I have few confusion like every where they written LDAP://somedomain/ but here I have https://somedomain.com another confusion is my test application is on one domain and provided domain is on another server. <br/>
<br/>
When I open links provided by client which is used for AD Authentication then it opens Open Office Web Access. <br/>
<br/>
I dont how to solve this problem. <br/>
<br/>
Thanks.

View the full article
 
Back
Top