F
fomalhaut
Hi All,
I'm builing an application that requires domain admin access to run,
and I'm trying to allow for the application to be run as a normal user
and allow the user to provide it with a username/password that has the
access.
I have a method that will check if the username/password is correct,
however, it will only authenticate the user running the program...
Here's the method:
public static bool validatePassword(string adUserName, string
adPassword)
{
DirectoryEntry de = new DirectoryEntry(null, "WDE" +
"\\" + adUserName, adPassword);
try
{
object o = de.NativeObject;
DirectorySearcher ds = new DirectorySearcher(de);
ds.Filter = "samaccountname=" + adUserName;
ds.PropertiesToLoad.Add("cn");
SearchResult sr = ds.FindOne();
if (sr == null) throw new Exception();
return true;
}
catch
{
return false;
}
}
If I check the username/password of the person that is running the
application, it works fine. If I provide any other username/password,
it fails in the "object o = de.NativeObject;".
Any ideas as to why it's happening?
Cheers,
Nathan Manzi
I'm builing an application that requires domain admin access to run,
and I'm trying to allow for the application to be run as a normal user
and allow the user to provide it with a username/password that has the
access.
I have a method that will check if the username/password is correct,
however, it will only authenticate the user running the program...
Here's the method:
public static bool validatePassword(string adUserName, string
adPassword)
{
DirectoryEntry de = new DirectoryEntry(null, "WDE" +
"\\" + adUserName, adPassword);
try
{
object o = de.NativeObject;
DirectorySearcher ds = new DirectorySearcher(de);
ds.Filter = "samaccountname=" + adUserName;
ds.PropertiesToLoad.Add("cn");
SearchResult sr = ds.FindOne();
if (sr == null) throw new Exception();
return true;
}
catch
{
return false;
}
}
If I check the username/password of the person that is running the
application, it works fine. If I provide any other username/password,
it fails in the "object o = de.NativeObject;".
Any ideas as to why it's happening?
Cheers,
Nathan Manzi