?
Solved

Nt User Management program

Posted on 2003-02-23
6
Medium Priority
?
251 Views
Last Modified: 2013-11-13
I have created a program in visual basic for getting user information and giving the option of unlocking the account and reseting the password.

I would like to store information on how many times someone has had there password changed through the program. I.e. sue wants to have her password changed the program then displays a label on how many times she had changed it.

It would also be good to be able to keep a history with dates :-)

any help would be good

Gary.
0
Comment
Question by:GaryBates
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 4

Expert Comment

by:Frog357
ID: 8005809
You can store this with the registry using GetSetting, SaveSetting, and GetAllSettings.  You could also use INI files and then you would need more work to use the API calls for Read & Write PrivateProfileString.

For the registry approach, you might save a key for each user as in:

SaveSetting "YourAppName", "USERNAME", "ResetCount", count


The to display on an label:
label1.caption = GetSetting("YourAppName", "USERNAME", "ResetCount", count)


You could save a value for the date reset and this can be done a few different ways.
One way could be:
Name the key value ("Reset" & Count)
so you'd have keys like:
Reset1
Reset2
Reset3

And each would contain the date it was reset for the value.
Create a listbox and a for loop using the count of resets and populate the list box with each date found.

This can be done many ways but hopefully this will give you ideas to start!
0
 
LVL 4

Expert Comment

by:Frog357
ID: 8005812
One correction:
The to display on an label:
label1.caption = GetSetting("YourAppName", "USERNAME", "ResetCount", 0)

The last value in GetSetting is the default value, if it's not found it should be 0.
0
 

Author Comment

by:GaryBates
ID: 8011557
I would prefer to use ann INI Setting as this is more universal and not restricted to one machine.

can you explain more about this?!?!?
0
 
LVL 4

Accepted Solution

by:
Frog357 earned 2000 total points
ID: 8015989
Add a new module to your project and add the following code:


Attribute VB_Name = "ReadWrite_INI"
Option Explicit

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
                        "GetPrivateProfileStringA" _
                        ( _
                        ByVal lpApplicationName As String, _
                        ByVal lpKeyName As Any, _
                        ByVal lpDefault As String, _
                        ByVal lpReturnedString As String, _
                        ByVal nSize As Long, _
                        ByVal lpFileName As String _
                        ) _
                        As Long

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias _
                        "WritePrivateProfileStringA" _
                        ( _
                        ByVal lpApplicationName As String, _
                        ByVal lpKeyName As Any, _
                        ByVal lpString As Any, _
                        ByVal lpFileName As String _
                        ) _
                        As Long

Private Declare Function WritePrivateProfileSection Lib "kernel32" Alias _
                        "WritePrivateProfileSectionA" _
                        ( _
                        ByVal lpAppName As String, _
                        ByVal lpString As String, _
                        ByVal lpFileName As String _
                        ) _
                        As Long

Public Function ReadINIFile(strINIFile As String, strSection As String, strKey As String) As String
    Dim strValue As String, sln As Long, sFile As String
    strValue = Space(255)
    sFile = strINIFile
    sln = GetPrivateProfileString(strSection, strKey, "0", strValue, Len(strValue), sFile)
    strValue = Left(strValue, sln)
    ReadINIFile = strValue
End Function

Public Function WriteINIFile(strINIFile As String, strSection As String, strKey As String, ByVal strValue As String) As Long
    Dim sln As Long, sFile As String
    sFile = strINIFile
    sln = WritePrivateProfileString(strSection, strKey, strValue, sFile)
    WriteINIFile = sln
End Function

Public Function DeleteSection(strINIFile As String, strSection As String) As Long
    Dim sln As Long, sFile As String
    sFile = strINIFile
    sln = WritePrivateProfileSection(strSection, vbNullString, sFile)
    DeleteSection = sln
End Function



Now to save a value to an ini file you would use:
WriteINIFile "C:\test.ini", "MAIN", "name", "value"

Reading ini file is:
sVarialbe = ReadINIFile("C:\test.ini", "MAIN", "nane")
Or
Msgbox ReadINIFile("C:\test.ini", "MAIN", "nane")


For these examples your ini file might look like this:

---start---
[MAIN]
name=value
----end----
0
 

Expert Comment

by:CleanupPing
ID: 9447566
GaryBates:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question