5 Replies - 6696 Views - Last Post: 01 June 2010 - 12:55 PM Rate Topic: -----

#1 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Problem in User Authentication

Posted 16 May 2010 - 09:23 PM

Dear All,

I have made function for disable the controls on the forms of all the project. The controls should be disabled in the general user and should be enabled in the admin user.


'The function which i made for the general User is:

User Sub()

with Form1

.command1.enabled = False
.command2.enabled = False

End With

End Sub

'The Function witch i made for admin user is:

Admin Sub()

with Form1


.command1.enabled = True
.command2.enabled = True
End With
End Sub


'I have made a login form and call tthese functions on this form the Coding is:

if text1.text = "" and text.text2 = "" then

Call user()

Form1.Show

End If

if text1.text = "Admin" and Text2.text = "Sales" then

Call admin()

Form1.Show

End If



Problem is that the controls on the forms for general user are disabled only one time when i exit that form and populate it again with out exiting from the system
it enables all the controls in the general user but it should be disabled in the general.

Please help me to resolve this problem
Thanks in Advance.

This post has been edited by JackOfAllTrades: 17 May 2010 - 07:23 AM
Reason for edit:: Added code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Problem in User Authentication

#2 Nikhil_07n  Icon User is offline

  • The cheese stands alone..
  • member icon

Reputation: 49
  • View blog
  • Posts: 2,489
  • Joined: 09-January 09

Re: Problem in User Authentication

Posted 17 May 2010 - 06:51 AM

With the code you're using, everything should be fine. When the program starts malfunctioning? Please elaborate.

P.S. : While posting, use code tags. :code:
Was This Post Helpful? 0
  • +
  • -

#3 naveed_786  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 306
  • Joined: 13-October 09

Re: Problem in User Authentication

Posted 17 May 2010 - 08:25 PM

Yes it works only for one time let me elaborate,

When general user log in then the form is main menu form is called the menu is enabled and when user click on any form it called out and the control placed on it are disabled as i did but when user cancel that form and click it again then the all controls on this are automatically enabled. What should i do and what is wrong with code?
Was This Post Helpful? 0
  • +
  • -

#4 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: Problem in User Authentication

Posted 01 June 2010 - 10:16 AM

View Postnaveed_786, on 17 May 2010 - 06:25 PM, said:

Yes it works only for one time let me elaborate,

When general user log in then the form is main menu form is called the menu is enabled and when user click on any form it called out and the control placed on it are disabled as i did but when user cancel that form and click it again then the all controls on this are automatically enabled. What should i do and what is wrong with code?



You are just hiding the the form, You will need to unload the form like this,

'the main form is form1, log in is frmlogin, active screen is form1
'when you log out use the below:
'start logout
     frmlogin.Visible = True
     Unload.Me
'end logout



when you log in it should be done this way:

'logging into form1, frmlogin is active
'start login
     Form1.Visible = True
     Unload.Me
'end login



The reason for this is so that you reset the whole form, I have had to do this with my programs, and it works well. If you would like you can even create users in an encrypted file and then use them to validate... but you will have to unload the forms from memory so that they truly reseed.

Best Wishes,

Jesse Fender

This post has been edited by chuckjessup: 01 June 2010 - 10:18 AM

Was This Post Helpful? 0
  • +
  • -

#5 chuckjessup  Icon User is offline

  • D.I.C Regular

Reputation: 33
  • View blog
  • Posts: 380
  • Joined: 26-October 09

Re: Problem in User Authentication

Posted 01 June 2010 - 10:52 AM

View Postnaveed_786, on 16 May 2010 - 07:23 PM, said:

Dear All,

I have made function for disable the controls on the forms of all the project. The controls should be disabled in the general user and should be enabled in the admin user.


'The function which i made for the general User is:

User Sub()

with Form1

.command1.enabled = False
.command2.enabled = False

End With

End Sub

'The Function witch i made for admin user is:

Admin Sub()

with Form1


.command1.enabled = True
.command2.enabled = True
End With
End Sub


'I have made a login form and call tthese functions on this form the Coding is:

if text1.text = "" and text.text2 = "" then

Call user()

Form1.Show

End If

if text1.text = "Admin" and Text2.text = "Sales" then

Call admin()

Form1.Show

End If



Problem is that the controls on the forms for general user are disabled only one time when i exit that form and populate it again with out exiting from the system
it enables all the controls in the general user but it should be disabled in the general.

Please help me to resolve this problem
Thanks in Advance.



Are you using MDI forms?
why are you doing so much work. Look you can save yourself a bunch of trouble here, may I show you what you may find to be easier?
good...
'Ok we are going to do three things... 1. create admin user and password with privs,
'2. create two general users with different privs,
'and 3. setup an error for incorrect users/passwords...
'first the General user
'Start log in
   If Text1.Text = "Jim" Then
      If Text2.Text = "Smith" Then
         Form1.Command1.Enabled = False
         From1.Command2.Enabled = False
      Else
      End If
   ElseIf Text1.Text = "someoneelse" Then
      If Text2.Text = "someOtherPa$$word" Then
         Form1.Command1.Enabled = True
         Form1.Command2.Enabled = False
      Else
      End If
 ' Now we will create the admin User. the above was so that you can see how to add hard coded users... Yo can also load from a file and so on...
   ElseIf Text1.Text = "Admin" Then
      If Text2.Text = "$aleS1" Then
         Form1.Command1.Enabled = True
         Form1.Command2.Enabled = True
      Else
      End If
'Now the creation of the error message. this is just for effect, the 'Else' statement
'will cause a halt in the code, and it will not proceed until correct information is given
   Else
      MsgBox "You have entered an incorrect Username and or Password. Please check to see that you have entered them correctly and try again.", vbCritical + vbOKonly, "Incorrect Login Credentials"
'end login validation
'Start login to next form
   Form1.Visible = True
   Unload.Me
'End login screen



That is a basic show of what you can do with If...Then statements, However if you are going to have a bunch of users, it would be wise to create a user directory with some form of encrypted users and passwords so that you can add users and it will not be like 10 pages of code... then follow the if statements to check the user and determine privileges based off of the user.

I think this would be easier, but that's just me...

Jesse Fender
Was This Post Helpful? 0
  • +
  • -

#6 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Problem in User Authentication

Posted 01 June 2010 - 12:55 PM

also here is a tutorial how to hide your folder to be accessed from explorer:
http://www.dreaminco...9-folder-hider/

i know it is a little primitive but if you encrypt the folder name using MD5(i think it was 1 way only) or this you can forget some one accessing it using explorer.

This post has been edited by NoBrain: 01 June 2010 - 12:56 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1