HI
I have one login form.
If the user submit there userid and password i have to compare the user given details with the
System Loginid and password.
Pls tell me how to do this
Thanks in advance
Prabhavathi
Loading
HI
I have one login form.
If the user submit there userid and password i have to compare the user given details with the
System Loginid and password.
Pls tell me how to do this
Thanks in advance
Prabhavathi
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
RealgarPosted Aug 24, 2005, 10:50 AM
password typed is valid using a dll.
private int LOGON32_PROVIDER_DEFAULT = 0;
private int LOGON32_LOGON_INTERACTIVE = 2; [DllImport("advapi32.dll")]
private static extern bool LogonUser (string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); public bool ValidateUser(string UserName, string Pwd, string Domain)
{
IntPtr tokenHandle = IntPtr.Zero;
try
{
//Call the LogonUser function to obtain a handle to an access token.
bool returnValue = LogonUser(UserName, Domain, Pwd, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);
if (!returnValue)
{
return false;
}
else
return true;
}
catch (Exception Ex)
{
throw Ex;
}
}
That should do it, if you want to get the username of the current user you can use
System.Environment.UserName instead of allowing the user to type one.
The domain you can get on 2 ways:
string Domain = System.Environment.UserDomainName;
if (Domain == ""){
//If you don't have a domain then The MachineName property gets the name of your computer.
Domain = System.Environment.MachineName;
}
(Heh this code can use some cleaning =P)