Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
High-powered ALLTRIM
Retrieving information about the main VFP window
Changing pitch and speed of a wave file
Exporting DLL icon resources as .ICO files
How to assemble an array of strings and pass it to external function
Retrieving Window Class information for the VFP window
Semi-transparent Form
Enumerating printer drivers installed
How to create non-blocking Winsock server
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
Extensible Storage Engine class library
How to find the application associated with a file name
Retrieving the name and type of all available RAS-capable devices
Enumerating servers of the specified type (e.g. SQL Server) in the primary domain
How to display Windows On-Screen Keyboard
Retrieving the interface–to–IP address mapping table
Retrieving the name of the primary domain controller (PDC) and join status information (NT/2000/XP)
Setting the volume label
GetProcessVersion points at target OS
How to delete all print jobs for a printer
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Reading the structure of VFP main menu
Retrieveing general information about the driver and data source associated with an ODBC connection
Retrieving Printer Device Context using PrintDlg function
Adding and deleting User Accounts

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
The class below wraps NetUserAdd, NetUserDel, NetUserGetInfo and NetUserSetInfo API calls with methods that can add, delete and modify user accounts on a server.

Use another example, Obtaining information about all user accounts on a server, to review the user accounts.
 
  Members area. Log in to view this example.
 
  User name:
  Password:
 
 
  Forgot your password?
 
  Sign up for
the Membership
 
 


User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
7151 bytes  
Created: 2005-02-07 19:34:02  
Modified: 2011-12-10 09:20:22  
Visits in 7 days: 135  
Listed functions:
GlobalAlloc
GlobalFree
GlobalSize
NetApiBufferFree
NetApiBufferSize
NetUserAdd
NetUserDel
NetUserGetInfo
NetUserSetInfo
Printer friendly API declarations
My comment:
In VFP versions 3 to 6 you may have to declare RtlMoveMemory as MemToStr and StrToMem not once but every time you call this function with either interface. Newer VFP versions allow at least two API declarations exist simultaneously.

Use this program code to test the class. Replace "MyServer" with an empty string to access user accounts on the local computer.
#DEFINE ERROR_ACCESS_DENIED 5
#DEFINE ERROR_BAD_NETPATH 53
#DEFINE NERR_UserNotFound 2221
#DEFINE NERR_UserExists 2224

LOCAL oUser As UserAccount
oUser = CREATEOBJECT("UserAccount", "MyServer", "FoxApp")

DO CASE

CASE oUser.errorcode = 0
        = MESSAGEBOX("User account " + oUser.GetUsername() +;
                " exists on " + oUser.GetServername() + ". ",;
                64, VERSION())

CASE oUser.errorcode = ERROR_BAD_NETPATH
        = MESSAGEBOX("Server " + oUser.GetServername() +;
                " not found or can not be accessed. ",;
                48, VERSION())

CASE oUser.errorcode = ERROR_ACCESS_DENIED
        = MESSAGEBOX("Access denied to Network " +;
                "Management Functions on " +;
                oUser.GetServername() +;
                ". ", 48, VERSION())

CASE oUser.errorcode = NERR_UserNotFound
        nSelect = MESSAGEBOX("User account " +;
                oUser.GetUsername() +;
                " not found on " + oUser.GetServername() + ". " +;
                CHR(13)+CHR(13) +;
                "Do you want to add this account? ",;
                32+4+256, VERSION())

        IF nSelect = 6
                IF oUser.UserAdd()
                        = MESSAGEBOX("User account " +;
                                oUser.GetUsername() +;
                                " added on " +;
                                oUser.GetServername() + ". ",;
                                64, VERSION())
                ELSE
                        = MESSAGEBOX("Method UserAdd " +;
                                "failed with error code " +;
                                TRANSFORM(oUser.errorcode) + ". ",;
                                48, VERSION())
                ENDIF
        ENDIF
ENDCASE

IF oUser.UserExists()
        oUser.SetComment("Temporary account. Delete after the testing.")
*        oUser.UserDel
ENDIF

* * *
Read an article HOW TO: Add a User to the Local System by Using Directory Services and Visual C# .NET on Microsoft Help and Support web site.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright © 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.226.5.29)
8.56 hrs.Function: 'GetKeyboardLayoutName'
Function group: 'Keyboard Input'
 Example: 'Creating irregularly shaped FoxPro form using transparency color key'
12.2 hrs.Function: 'waveInOpen'
 Example: 'Using the RestartDialog function -- restarting Windows'
15.84 hrs.Function: 'WinHttpConnect'
 Example: 'Accessing examples contained in this reference through Web Services'
 Function: 'DeleteFileTransacted'
Function group: 'File Management'
23.2 hrs.Example: 'GetFocus returns a HWND value'
 Example: 'Testing serial ports'
1 day(s)Example: 'URL: splitting into its component parts'
Google
Advertise here!