DOCUMENT:Q190741 30-SEP-1999 [foxpro] TITLE :HOWTO: Get User Information Using ADSI PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:6.0; winnt:2.5 OPER/SYS: KEYWORDS:kbcode kbADSI kbCOMt kbvfp600 kbGrpDSFox kbDSupport ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, version 6.0 - Microsoft Active Directory Service Interfaces, version 2.5 ------------------------------------------------------------------------------- SUMMARY ======= The Active Directory Service Interfaces (ADSI) can be used to obtain network user information from within Visual FoxPro. This article shows an example of how to obtain this information. MORE INFORMATION ================ NOTE: In order to use the following example, the Active Directory Service Interfaces must be installed from the following Web site or the MSDN CD: http://www.microsoft.com/windows/server/Technical/directory/ ADSI is a COM-based interface for accessing directory services. Each element of the network, such as users, printers and computers, can be treated as an object. Accessing the user object's properties allows the developer to get information about the user. The following code demonstrates how to do this. Save the following code to a program file and run the program. Sample Code ----------- *-- Code begins here. PUBLIC oform1 ON ERROR DO errorhnd oform1=NEWOBJECT("form1") oform1.Show RETURN PROCEDURE errorhnd DO CASE CASE ERROR() = 1426 *-- We have an OLE error code. *-- Insert code to handle it as needed. OTHERWISE *-- We have an error not related to ADSI. *-- Error handling would normally be placed here. =MESSAGEBOX(STR(ERROR()) +": " + MESSAGE(), 0, "Error") ENDCASE ENDPROC DEFINE CLASS form1 AS form Height = 253 Width = 457 DoCreate = .T. AutoCenter = .T. Caption = "Form1" Name = "form1" ADD OBJECT text1 AS textbox WITH ; Value = "WinNT://MyServer", ; Height = 23, ; Left = 12, ; Top = 206, ; Width = 238, ; Name = "Text1" ADD OBJECT label1 AS label WITH ; Caption = "ADS Path to Server:", ; Height = 25, ; Left = 12, ; Top = 181, ; Width = 202, ; Name = "Label1" ADD OBJECT cmdfind AS commandbutton WITH ; Top = 192, ; Left = 283, ; Height = 37, ; Width = 97, ; Caption = "\