Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Smart Card Database Query Functions
URL: splitting into its component parts
Simple MAPI: how to pick an email recipient from Outlook Express address book
Testing serial ports
Retrieving local computer and user names
Shortcut Menu Class
Winsock: creating a socket that is bound to a specific service provider
Winsock: initializing the service in the VFP application
Displaying all TCP connections for the local system
How to retrieve configuration data for a specified printer stored in the registry (PrinterDriverData key)
Locking and unlocking file of a VFP table
Passing data records between VFP applications via the Clipboard
Placing an arbitrary rectangular area of main VFP window on the Clipboard
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Browsing Windows Known Folders (Special Folders)
Class library providing access to the System Registry
Displaying standard progress dialog box when copying files
Enumerating sessions established on a server
How to register custom Event Log source
How to Start a Process as Another User (NT/XP/2K)
Quering a waveform-audio input device
Using NetWkstaTransportEnum to obtain MAC Address of remote server
Winsock: retrieving information about available transport protocols
Adding and deleting User Accounts
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: 90  
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 (50.16.108.167)
3.6 hrs.Example: 'Retrieving top-child window for the VFP form'
 Example: 'Retrieving list of Global Atom names'
5.43 hrs.Function: 'GetTextExtentPoint32'
 Example: 'Creating a clipping region from the path selected into the device context of a form'
5.81 hrs.Function: 'FindResource'
Function group: 'Resource'
 Example: 'Custom HttpRequest class (WinHTTP)'
 Function: 'GdipDrawRectangle'
Function group: 'GDI+ Graphics'
6.58 hrs.Function: 'SetMenu'
 Function: 'GdipSetImagePalette'
Function group: 'GDI+ Image'
 Example: 'Confining Windows calculator inside the VFP main window'
Google
Advertise here!