Active Directory – Anvil of Time https://anvil-of-time.com Nature Forges Everything on the Anvil of Time Tue, 09 Mar 2021 17:14:32 +0000 en-US hourly 1 PowerBuilder – Getting Active Directory information https://anvil-of-time.com/powerbuilder/powerbuilder-getting-active-directory-information/ Tue, 28 Sep 2010 01:00:33 +0000 http://anvil-of-time.com/wordpress/?p=394 Here is a handy bit of OLE to retrieve Active Directory information.

oleobject ads
string ls_stuff
ads = CREATE OleObject

ads.ConnectToNewObject( "ADSystemInfo" )

ls_stuff = 'User: ' + String(ads.UserName)
ls_stuff += '~n~r' + 'Computer: ' + string(ads.ComputerName)
ls_stuff += '~n~r' + 'Domain: ' + string(ads.DomainDNSName)
ls_stuff += '~n~r' + 'Domain short: ' + string(ads.DomainShortName)
ls_stuff += '~n~r' + 'Forest: ' + string(ads.ForestDNSName)
ls_stuff += '~n~r' + 'Native Mode: ' + string(ads.IsNativeMode)
ls_stuff += '~n~r' + 'PDCRoleOwner: ' + string(ads.PDCRoleOwner)
ls_stuff += '~n~r' + 'SchemaRoleOwner: ' + string(ads.SchemaRoleOwner)
ls_stuff += '~n~r' + 'Site: ' + string(ads.SiteName)


MessageBox("Active Directory - Information",ls_stuff)
DESTROY(ads)

Sample output from the above example:

More information here:

From the Microsoft link

ADSystemInfo interface defines the following properties. All are read only

ComputerName
Retrieves the distinguished name of the local computer.

DomainDNSName
Retrieves the DNS name of the local computer domain, for example “example.fabrikam.com”.

DomainShortName
Retrieves the short name of the local computer domain, for example “myDom”.

ForestDNSName
Retrieves the DNS name of the local computer forest.

IsNativeMode
Determines whether the local computer domain is in native or mixed mode.

PDCRoleOwner
Retrieves the distinguished name of the NTDS-DSA object for the DC that owns the primary domain controller role in the local computer domain.

SchemaRoleOwner
Retrieves the distinguished name of the NTDS-DSA object for the DC that owns the schema role in the local computer forest.

SiteName
Retrieves the site name of the local computer.

UserName
Retrieves the Active Directory distinguished name of the current user, which is the logged-on user or the user impersonated by the calling thread.

]]>