Reputation: 349
In my web app, I have a login.aspx
page. When I enter the username and password, I need to validate it on a remote server. They only provide me the server name (path), and domain name (don't know the password and username). How can it be done?
My web.config
<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="10"/>
</authentication>
I have read LDAP Authentication in ASP.Net MVC but, in the membership provider, they wrote in the connection, password and username.
What should i do?
Upvotes: 0
Views: 5930
Reputation: 7827
If all you need to do is verify that the user exists and the password is valid, you can use something like this: The arguments are domain name, USER id and USER password. Since we're not querying anything, non-admin privileges are OK.
public static bool LogonValid(string ldapDomain, string userName, string password) {
DirectoryEntry de = new DirectoryEntry(@"LDAP://" + ldapDomain, userName, password);
try {
object o = de.NativeObject;
return true;
}
catch (Exception ex) {
logger.Error(ex.ToString());
return false;
}
}
There are probably reasons that this won't work in every situation, but it's worked for me so far.
Upvotes: 1
Reputation: 151720
Like the answer there says:
The connection protection, user name and pwd are for the account that has access to query AD on behalf of the system. Depending on the security of your network this may have to be setup or you won't be able to query AD to authenticate the user.
It depends on the configuration of the server how you should authenticate.
Upvotes: 1