{"id":394,"date":"2010-09-27T20:00:33","date_gmt":"2010-09-28T01:00:33","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=394"},"modified":"2021-03-09T12:14:32","modified_gmt":"2021-03-09T17:14:32","slug":"powerbuilder-getting-active-directory-information","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-getting-active-directory-information\/","title":{"rendered":"PowerBuilder &#8211; Getting Active Directory information"},"content":{"rendered":"<p>Here is a handy bit of OLE to retrieve Active Directory information.<\/p>\n<pre name=\"code\" class=\"VB\">oleobject ads\nstring ls_stuff\nads = CREATE OleObject\n\nads.ConnectToNewObject( &quot;ADSystemInfo&quot; )\n\nls_stuff = &#039;User: &#039; + String(ads.UserName)\nls_stuff += &#039;~n~r&#039; + &#039;Computer: &#039; + string(ads.ComputerName)\nls_stuff += &#039;~n~r&#039; + &#039;Domain: &#039; + string(ads.DomainDNSName)\nls_stuff += &#039;~n~r&#039; + &#039;Domain short: &#039; + string(ads.DomainShortName)\nls_stuff += &#039;~n~r&#039; + &#039;Forest: &#039; + string(ads.ForestDNSName)\nls_stuff += &#039;~n~r&#039; + &#039;Native Mode: &#039; + string(ads.IsNativeMode)\nls_stuff += &#039;~n~r&#039; + &#039;PDCRoleOwner: &#039; + string(ads.PDCRoleOwner)\nls_stuff += &#039;~n~r&#039; + &#039;SchemaRoleOwner: &#039; + string(ads.SchemaRoleOwner)\nls_stuff += &#039;~n~r&#039; + &#039;Site: &#039; + string(ads.SiteName)\n\n\nMessageBox(&quot;Active Directory - Information&quot;,ls_stuff)\nDESTROY(ads)<\/pre>\n<p>Sample output from the above example:<\/p>\n<p><a href=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2021\/03\/ADinfo.png\"><img loading=\"lazy\" class=\"wp-image-1836 aligncenter\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2021\/03\/ADinfo-300x87.png\" alt=\"\" width=\"569\" height=\"165\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2021\/03\/ADinfo-300x87.png 300w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2021\/03\/ADinfo-150x43.png 150w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2021\/03\/ADinfo.png 731w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/a><\/p>\n<p>More information here:<\/p>\n<p>From the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa705962%28VS.85%29.aspx\">Microsoft link<\/a><\/p>\n<p>ADSystemInfo interface defines the following properties. All are read only<\/p>\n<p>ComputerName<br \/>\nRetrieves the distinguished name of the local computer.<\/p>\n<p>DomainDNSName<br \/>\nRetrieves the DNS name of the local computer domain, for example &#8220;example.fabrikam.com&#8221;.<\/p>\n<p>DomainShortName<br \/>\nRetrieves the short name of the local computer domain, for example &#8220;myDom&#8221;.<\/p>\n<p>ForestDNSName<br \/>\nRetrieves the DNS name of the local computer forest.<\/p>\n<p>IsNativeMode<br \/>\nDetermines whether the local computer domain is in native or mixed mode.<\/p>\n<p>PDCRoleOwner<br \/>\nRetrieves the distinguished name of the NTDS-DSA object for the DC that owns the primary domain controller role in the local computer domain.<\/p>\n<p>SchemaRoleOwner<br \/>\nRetrieves the distinguished name of the NTDS-DSA object for the DC that owns the schema role in the local computer forest.<\/p>\n<p>SiteName<br \/>\nRetrieves the site name of the local computer.<\/p>\n<p>UserName<br \/>\nRetrieves the Active Directory distinguished name of the current user, which is the logged-on user or the user impersonated by the calling thread.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a handy bit of OLE to retrieve Active Directory information. oleobject ads string ls_stuff ads = CREATE OleObject ads.ConnectToNewObject( &quot;ADSystemInfo&quot; ) ls_stuff = &#039;User: &#039; + String(ads.UserName) ls_stuff += &#039;~n~r&#039; + &#039;Computer: &#039; + string(ads.ComputerName) ls_stuff += &#039;~n~r&#039; + &#039;Domain: &#039; + string(ads.DomainDNSName) ls_stuff += &#039;~n~r&#039; + &#039;Domain short: &#039; + string(ads.DomainShortName) ls_stuff&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[34,12,13,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/394"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=394"}],"version-history":[{"count":10,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/394\/revisions"}],"predecessor-version":[{"id":1835,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/394\/revisions\/1835"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}