Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've been using this little function without any issue for the past few years to validate user credentials. The createPrincipalContext method returns a PrincipalContext with ContextType.Machine and the machine name.

public static bool ValidateCredentials(string username, string password, string domain = null) {
    try {
        using (var principalContext = createPrincipalContext(username, domain)) {
            username = GetLoginInfo(username).Username;
            // validate the credentials
            if (principalContext.ValidateCredentials(username, password)) {
                //once valid check if account is enabled
                using (UserPrincipal user = UserPrincipal.FindByIdentity(principalContext, username)) {
                    return user.Enabled.GetValueOrDefault(false);
                }
            }
        }
    } catch (PrincipalOperationException e) {
        traceError(e);
    } catch (Exception e) {
        traceError(e);
    }
    return false;
}

My development machine automatically updated to the latest version of Windows 10 this recently, and since then, principalContext.ValidateCredentials has been throwing the following exception.

System.IO.FileNotFoundException: The system cannot find the file specified.

Other than the machine update nothing else was changed. I've spend the last few days searching the net for what may have caused the issue.

Does anyone have any experience in identifying what may have been the cause and if possible, a solution?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
379 views
Welcome To Ask or Share your Answers For Others

1 Answer

One final Google before I started rolling back my machine to the previous build and I found this https://connect.microsoft.com/IE/feedback/details/1904887/windows-10-insider-preview-build-10565

the problem is caused by missing registry entries in HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindows NTCurrentVersion, specifically: RegisteredOwner and RegisteredOrganization

EDIT: Run the Registry Editor by pressing Windows R and typing regedit.exe. Browse to the location above

Just right click on the CurrentVersion in the Registry Editor and select New > String Value. After you add each entry ( RegisteredOwner and RegisteredOrganization ) edit their values. You can use your username and company name respectively.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...