{"id":85,"date":"2025-09-09T04:40:26","date_gmt":"2025-09-09T04:40:26","guid":{"rendered":"https:\/\/vinpearl.ca\/?p=85"},"modified":"2025-09-13T07:22:02","modified_gmt":"2025-09-13T07:22:02","slug":"ad-enum","status":"publish","type":"post","link":"https:\/\/vinpearl.ca\/index.php\/2025\/09\/09\/ad-enum\/","title":{"rendered":"AD enum"},"content":{"rendered":"\n<p>net user<\/p>\n\n\n\n<p>net user \/domain<\/p>\n\n\n\n<p>net user username \/domain<\/p>\n\n\n\n<p>net group \/domain<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><em>powershell -ep bypass<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>build the full LDAP ADspath,LDAP:\/\/hostname[:portnumber][\/distinguishedName]<\/p>\n\n\n\n<p>PDC,primary domain controller,PdcRoleOwner property.<\/p>\n\n\n\n<p>$domainObj = <em>[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()<\/em><\/p>\n\n\n\n<p><em>$PDC = $domainObj.PdcRoleOwner.Name<\/em><\/p>\n\n\n\n<p>DN,DistinguishedName,uniquely id and obj in AD,<\/p>\n\n\n\n<p><em>$DN = ([adsi]&#8221;).distinguishedName<\/em><\/p>\n\n\n\n<p>$LDAP = &#8220;LDAP:\/\/$PDC\/$DN&#8221;<\/p>\n\n\n\n<p>ADSI wrapper.<\/p>\n\n\n\n<p>ADSI is a <strong>COM interface<\/strong> that ships with Windows,doesn\u2019t require installing RSAT or the AD DS role<\/p>\n\n\n\n<p>AD module isn\u2019t present on client machines, get-aduser installed on DC by defaultas part of RSAT,rarely on clients.<br><\/p>\n\n\n\n<p>([adsi]&#8221;).distinguishedName,[adsi]&#8221; defaults to the <strong>domain root<\/strong>,the <strong>top of the AD hierarchy<\/strong> for searches<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><em>$direntry = New-object System.DirectoryServices.DirectoryEntry($LDAP)<\/em><\/p>\n\n\n\n<p>encap an obj in AD.can pass credentials to auth to domain.<\/p>\n\n\n\n<p><em>$dirsearcher = New-object System.DirectoryServices.DirectorySearcher($direntry)<\/em><\/p>\n\n\n\n<p>specify the ad service in thr form of &#8216;SearchRoot&#8217; property.<\/p>\n\n\n\n<p><em>$dirsearcher.findall()<\/em><\/p>\n\n\n\n<p>setup a filter sift through attribute applied  to all user,computer,group objs, samAccountType.<\/p>\n\n\n\n<p><em>$dirsearcher.filter=&#8221;samAccountType=xxxxxxxxx&#8221;<\/em><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>encap to a function:<\/p>\n\n\n\n<p>Import-Module xxx\\adenum_2.ps1<\/p>\n\n\n\n<p>FuncName -para &#8220;samAccountType=805306368&#8221;<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>objectClass vs. objectCategory<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>LDAP filters are written in <strong>Polish notation (prefix notation)<\/strong> \u2014 the operator goes first, then the conditions.e.g. (<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-secondary-color\">&amp;<\/mark>(objectCategory=group)(cn=Domain Admins))<\/p>\n","protected":false},"excerpt":{"rendered":"<p>net user net user \/domain net user username \/domain net group \/domain powershell -ep bypass build the full LDAP ADspath,LDAP:\/\/hostname[:portnumber][\/distinguishedName] PDC,primary domain controller,PdcRoleOwner property. $domainObj = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() $PDC = $domainObj.PdcRoleOwner.Name DN,DistinguishedName,uniquely id and obj in AD, $DN = ([adsi]&#8221;).distinguishedName $LDAP = &#8220;LDAP:\/\/$PDC\/$DN&#8221; ADSI wrapper. ADSI is a COM interface that ships with Windows,doesn\u2019t require installing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[13,11],"_links":{"self":[{"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/posts\/85"}],"collection":[{"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":14,"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/posts\/85\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vinpearl.ca\/index.php\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}