We have PCs out on the Manufacturing floor that have public access and are
always logged in using a public/global profile.
Whenever someone needs to access sensitive information, we want to verify
they have permission by checking their username/password on our Active
Directory server.
How should I authenticate our users using a local Active Directory server? I
have tried the code below, but it returned a COMException 0x80005000 "Unknown
error":
Code:
public static bool Authenticate(st ring domain, string userName, string
passWord) {
string path = string.Format(" LDAP://{0}", domain);
string domUser = domain + @"\" + userName;
DirectoryEntry entry = new DirectoryEntry( string.Format(" LDAP://{0}",
path), domUser, passWord);
entry.Authentic ationType = AuthenticationT ypes.ServerBind ;
try {
object nativeObj = entry.NativeObj ect;
Console.WriteLi ne(string.Forma t("Username '{0}' Authenticated",
userName));
return true;
} catch (COMException e) {
MessageBox.Show (string.Format( "Username '{0}' Not Authenticated:\ n{1}",
userName, e.Message));
} catch (Exception e) {
MessageBox.Show (string.Format( "Username '{0}' Not Authenticated:\ n{1}",
userName, e.Message));
}
return false;
}
Could someone offer a suggestion? I tried Googling, but most solutions
appear to be tailored for ASP.NET - we are only using WinForms.
Is ServerBind incorrect?
Whenever I bring up the Windows Login information (CTRL-ALT-DEL), I can see
that my personal username is "ACPINC\cp-jpool" - and this is what I send in
along with my password using the path LDAP://ACPINC", but it does not work.
Our "Know-It-All" System Administrator ...doesn't! He has nearly completed
his extensive 6-month training at one of the prestigious online websites, so
asking him produced me the useless "I don't know" answer.
Could someone offer a suggestion?
always logged in using a public/global profile.
Whenever someone needs to access sensitive information, we want to verify
they have permission by checking their username/password on our Active
Directory server.
How should I authenticate our users using a local Active Directory server? I
have tried the code below, but it returned a COMException 0x80005000 "Unknown
error":
Code:
public static bool Authenticate(st ring domain, string userName, string
passWord) {
string path = string.Format(" LDAP://{0}", domain);
string domUser = domain + @"\" + userName;
DirectoryEntry entry = new DirectoryEntry( string.Format(" LDAP://{0}",
path), domUser, passWord);
entry.Authentic ationType = AuthenticationT ypes.ServerBind ;
try {
object nativeObj = entry.NativeObj ect;
Console.WriteLi ne(string.Forma t("Username '{0}' Authenticated",
userName));
return true;
} catch (COMException e) {
MessageBox.Show (string.Format( "Username '{0}' Not Authenticated:\ n{1}",
userName, e.Message));
} catch (Exception e) {
MessageBox.Show (string.Format( "Username '{0}' Not Authenticated:\ n{1}",
userName, e.Message));
}
return false;
}
Could someone offer a suggestion? I tried Googling, but most solutions
appear to be tailored for ASP.NET - we are only using WinForms.
Is ServerBind incorrect?
Whenever I bring up the Windows Login information (CTRL-ALT-DEL), I can see
that my personal username is "ACPINC\cp-jpool" - and this is what I send in
along with my password using the path LDAP://ACPINC", but it does not work.
Our "Know-It-All" System Administrator ...doesn't! He has nearly completed
his extensive 6-month training at one of the prestigious online websites, so
asking him produced me the useless "I don't know" answer.
Could someone offer a suggestion?
Comment