|
public static DotnetAD.LoginResult Login(string UserName, string Password)
{
//first, check if the logon exists based on the username and password
//DirectoryEntry de = GetUser(UserName,Password);
if(IsUserValid(UserName,Password))
{
DirectoryEntry de = GetUser(UserName);
if(de !=null)
{
//convert the accountControl value so that a logical operation can be performed
//to check of the Disabled option exists.
int userAccountControl = Convert.ToInt32(de.Properties["userAccountControl"][0]);
de.Close();
//if the disabled item does not exist then the account is active
if(!IsAccountActive(userAccountControl))
{
return LoginResult.LOGIN_USER_ACCOUNT_INACTIVE;
}
else
{
return LoginResult.LOGIN_OK;
}
}
else
{
return LoginResult.LOGIN_USER_DOESNT_EXIST;
}
}
else
{
return LoginResult.LOGIN_USER_DOESNT_EXIST;
}
}
|