-
February 27th, 2008, 04:41 AM
#1
use Windows Username and Password to login my app...
Hi,
I don't want to store username and password into the database or file. I want that user will login through the logged in UserName Password and domain. for e.g.
If User ABC is logged into the system, then once he open the app, he will prompt for password, so that username will be the windows username and password has to be entered correctly.
Please let me know how I can achieve it....
.
Hope that Helps a Bit, but Sorry if it doesn't.
Dont forget to Rate the Post...
Thanks & Regards
Manu Raj
Nothings is Impossible in this World even Impossible says "I M possible"...
-
February 27th, 2008, 05:42 AM
#2
Re: use Windows Username and Password to login my app...
All I'll give you is that you can use either the GetUserName or the GetUserNameEx API s to get the User name(s), to get the password, hmm I think that'll be too much of a risk posting such code on a public forum, at least IMHO.
-
February 28th, 2008, 12:42 AM
#3
-
February 28th, 2008, 12:57 AM
#4
Re: use Windows Username and Password to login my app...
With what ¿ It cannot be with the Username ( not if you followed my advice ). As I also said ( to you ) in this thread and in numerous PMs, I don't think it's allowed to post such info about the Password here, and i don't want to ( and not going to ) break any rules..
-
February 28th, 2008, 01:05 AM
#5
Re: use Windows Username and Password to login my app...
Hey....
Hurrey I just got it now......
Thanks Hannes...
.
Hope that Helps a Bit, but Sorry if it doesn't.
Dont forget to Rate the Post...
Thanks & Regards
Manu Raj
Nothings is Impossible in this World even Impossible says "I M possible"...
-
February 28th, 2008, 01:07 AM
#6
Re: use Windows Username and Password to login my app...
I use below code... It will not brings up the password but it will validate the user...
Code:
Public Declare Function NetUserChangePassword Lib "netapi32.dll" (ByVal sDomain As String, ByVal sUserName As String, ByVal sOldPassword As String, ByVal sNewPassword As String) As Long
Code:
Public Function UserValidate(sUserName As String, sPassword As String, Optional sDomain As String) As Boolean
Dim lReturn As Long
Const NERR_BASE = 2100
Const NERR_PasswordCantChange = NERR_BASE + 143
Const NERR_PasswordHistConflict = NERR_BASE + 144
Const NERR_PasswordTooShort = NERR_BASE + 145
Const NERR_PasswordTooRecent = NERR_BASE + 146
Const NERR_Cant_Change = 5 '"User can't change password" is checked
If Len(sDomain) = 0 Then
sDomain = Environ$("USERDOMAIN")
End If
'Call API to check password.
lReturn = NetUserChangePassword(StrConv(sDomain, vbUnicode), StrConv(sUserName, vbUnicode), StrConv(sPassword, vbUnicode), StrConv(sPassword, vbUnicode))
'Test return value.
Select Case lReturn
Case 0, NERR_PasswordCantChange, NERR_PasswordHistConflict, NERR_PasswordTooShort, NERR_PasswordTooRecent
UserValidate = True
Case 5
UserValidate = False
MsgBox "The user is not allowed to change passwords. Please remove the restriction.", vbCritical, "System Error"
Case Else
UserValidate = False
End Select
End Function
Private Sub Command1_Click()
If UserValidate(Text1.Text, Text2.Text, Text3.Text) = True Then
MsgBox "OK"
Else
MsgBox "Not OK"
End If
End Sub
Hope that Helps a Bit, but Sorry if it doesn't.
Dont forget to Rate the Post...
Thanks & Regards
Manu Raj
Nothings is Impossible in this World even Impossible says "I M possible"...
-
February 28th, 2008, 02:11 AM
#7
Re: use Windows Username and Password to login my app...
You can't use StrConv(), as far as I can tell. Need a byte-array
'Converts a Unicode-String to a Unicode-Byte-Array.
'Is used because VB always passes Strings as ANSI instead of Unicode.
-
February 28th, 2008, 02:24 AM
#8
Re: use Windows Username and Password to login my app...
But it is working fine....
Hope that Helps a Bit, but Sorry if it doesn't.
Dont forget to Rate the Post...
Thanks & Regards
Manu Raj
Nothings is Impossible in this World even Impossible says "I M possible"...
-
February 28th, 2008, 09:40 PM
#9
Re: use Windows Username and Password to login my app...
Code:
Dim uname As String
uname = Environ$("Username")
MsgBox "Username = " & uname
Be nice to Harley riders...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|