Ldap – Why can’t Get-ADObject -identity against a GC use the SamAccountname, given that this attribute is

active-directoryldap

Why can't Get-ADObject against a GC use the SamAccountname for the -identity parameter, given that this attribute is in the GC? The help for that cmdlet lists only DN and GUID as acceptable for -identity, and indeed only those work. But its just more common to need to query the GC on a list of logon names (SamAccountnames) that could be in any domain in the forest, which is my case here.

Is this a limitation of LDAP, the GC, the partial attribute set, or the PS cmdlets?

Best Answer

You probably want to use Get-ADUser if you're trying to get a list of user logon names, or Get-ADComputer if you're looking for systems which log on as well.

Or if you for some other reason need to use Get-ADObject, you can use a filter on SAMAccountNames instead: Get-ADObject -f {SAMAccountName -like "*searchfilter*"}

I'm not familiar with the design decisions behind why only certain attributes are valid. But, I would imagine that you cannot query against all AD Objects by SAMAccountName because most AD objects don't have a SAMAccountName.