nolint:revive Use LogonUser to check if the provided password is correct. https://msdn.microsoft.com/en-us/library/windows/desktop/aa378184(v=vs.85).aspx
(username, password string)
| 55 | // |
| 56 | // https://msdn.microsoft.com/en-us/library/windows/desktop/aa378184(v=vs.85).aspx |
| 57 | func ValidUserPassword(username, password string) error { |
| 58 | const LOGON32_LOGON_NETWORK = 3 //nolint:revive |
| 59 | const LOGON32_PROVIDER_DEFAULT = 0 //nolint:revive |
| 60 | |
| 61 | if err := procLogonUser.Find(); err != nil { |
| 62 | return err |
| 63 | } |
| 64 | puser, err := windows.UTF16PtrFromString(username) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | ppass, err := windows.UTF16PtrFromString(password) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | var token windows.Handle |
| 73 | r1, _, e1 := syscall.SyscallN(procLogonUser.Addr(), |
| 74 | uintptr(unsafe.Pointer(puser)), // LPTSTR lpszUsername, |
| 75 | uintptr(0), // LPTSTR lpszDomain, |
| 76 | uintptr(unsafe.Pointer(ppass)), // LPTSTR lpszPassword, |
| 77 | LOGON32_LOGON_NETWORK, // DWORD dwLogonType, |
| 78 | LOGON32_PROVIDER_DEFAULT, // DWORD dwLogonProvider, |
| 79 | uintptr(unsafe.Pointer(&token)), // PHANDLE phToken |
| 80 | ) |
| 81 | if r1 == 0 { |
| 82 | if e1 == 0 { |
| 83 | return syscall.EINVAL |
| 84 | } |
| 85 | return e1 |
| 86 | } |
| 87 | windows.CloseHandle(token) //nolint:errcheck |
| 88 | return nil |
| 89 | } |
| 90 | |
| 91 | var _ = Describe("WindowsPlatform", func() { |
| 92 | var ( |
no outgoing calls
no test coverage detected