Article ID: 197948 - Last Review: October 9, 2006 - Revision: 4.0

How To Get Domain Information Using ADSI

This article was previously published under Q197948

On This Page

Expand all | Collapse all

SUMMARY

You can use the Active Directory Service Interfaces (ADSI) to obtain network domain information from within Visual FoxPro. This article shows an example of how to obtain this information.

MORE INFORMATION

NOTE: To use the following example, you must install the Active Directory Service from the following Web site or the Microsoft Developer Network CD:
http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/activedirectory/default.mspx (http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/activedirectory/default.mspx)
ADSI is a COM-based interface for accessing directory services. You can treat each element of the network, such as users, printers, and computers, as an object. Accessing the properties of the domain object allows the developer to get information about the domain. 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.
*-- Replace MyDomain with a valid domain name.
oDomain = Getobject("WinNT://MyDomain")

*-- Collect the properties of the oDomain object and display them.
lsInfo = "Minimum Password Length:  " + ;

         STR(oDomain.MinPasswordLength) + CHR(13) + ;
         "Minimum Password Age:  " + ;
         STR(oDomain.MinPasswordAge) + CHR(13) + ;
         "Maximum Password Age:  " + ;
         STR(oDomain.MaxPasswordAge) + CHR(13) + ;
         "Maximum Bad Passwords:  " + ;
         STR(oDomain.MaxBadPasswordsAllowed) + CHR(13) + ;
         "Password History Length:  " + ;
         STR(oDomain.PasswordHistoryLength) + CHR(13) + ;
         "Auto Unlock Interval:  " + ;
         STR(oDomain.AutoUnlockInterval) + CHR(13) + ;
         "Lock Out Observation Interval:  " + ;
         STR(oDomain.LockOutObservationInterval)

WAIT WINDOW lsInfo
*-- Code ends here
				

REFERENCES

Visual Studio Microsoft Developer Network Library, version 6.0; search on: "ADSI Domain Object"

For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
http://msdn.microsoft.com/ie/ (http://msdn.microsoft.com/ie/)

http://support.microsoft.com/iep (http://support.microsoft.com/iep)

APPLIES TO
  • Microsoft Visual FoxPro 6.0 Professional Edition
  • Microsoft Active Directory Service Interfaces 2.0
  • Microsoft Active Directory Service Interfaces 2.5
Keywords: 
kbhowto KB197948
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations