Here's an example how to authenticate a username and password against Windows with the PrincipalContext class and the ValidateCredentials-method.
boolean isAuthenticated = false; System.DirectoryServices.AccountManagement.PrincipalContext principalContext; ; principalContext = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType::Domain, "contoso.com"); isAuthenticated = principalContext.ValidateCredentials("username", "password"); principalContext.Dispose(); if (isAuthenticated) { //do something } else { //do something }
Update: (15/07/11) And bcause of the Google search keywords: The username and password for the contoso.com VPC are Administrator and Passw0rd (or pass@word1 depends on the vpc) ... ;-)
No comments:
Post a Comment