We have an web application developed using c#(VS 2008/3.5 framework). The application uses the mode of authentication as "Windows" with a service account present in domain (Domain1) to run the application as ASP.Net user. We have authentication to be done
for the users present in different domain (Domain 2). When authentication is done using the directory services(Directory searcher), we are able to connect to LDAP of domain1 and bind it, so that user is authenticated. Also, the user is able to be authenticated
if the user has been migrated from domain1 to domain 2. However, if there is a user id directly created in domain 2, then application is not able to bind to Domain2 (during the LDAP authentication) and hence, this user is not being authenticated by the application.
Please suggest the solution regarding the same.
prafulrk
0 Points
1 Post
LDAP user Authentication using Directory searcher in c#
Jan 11, 2013 09:45 AM|LINK
We have an web application developed using c#(VS 2008/3.5 framework). The application uses the mode of authentication as "Windows" with a service account present in domain (Domain1) to run the application as ASP.Net user. We have authentication to be done for the users present in different domain (Domain 2). When authentication is done using the directory services(Directory searcher), we are able to connect to LDAP of domain1 and bind it, so that user is authenticated. Also, the user is able to be authenticated if the user has been migrated from domain1 to domain 2. However, if there is a user id directly created in domain 2, then application is not able to bind to Domain2 (during the LDAP authentication) and hence, this user is not being authenticated by the application. Please suggest the solution regarding the same.
<authentication mode="Windows"/>
<identity impersonate="true" userName="domain1\svc_acc" password="***"/>
public bool ValidateUidPwdAndGetUserTypeGlobal(string TPXId, string password)
{
string strADPath = "LDAP://a.b.c/dc=a,dc=b,dc=c";
try
{
DirectoryEntry objDirEntry = new DirectoryEntry(strADPath, TPXId, password);
DirectorySearcher search = new DirectorySearcher(objDirEntry);
search.Filter = "(samaccountname=" + TPXId + ")";
SearchResult result = search.FindOne();
if (null == result)
{
return false;
}
else
return true;
}
catch (Exception ex)
{
return false;
}
}
Angie xu - M...
All-Star
18045 Points
1550 Posts
Microsoft
Re: LDAP user Authentication using Directory searcher in c#
Jan 15, 2013 10:57 AM|LINK
Hi prafulrk
Perhaps this thread is a good reference for you about cross domain authentication using DirectoryServices in stackoverflow.
Cross Domain Authentication using DirectoryServices
http://stackoverflow.com/questions/9362724/cross-domain-authentication-using-directoryservices
hope it helps you,
Kind regards
Feedback to us
Develop and promote your apps in Windows Store