0

Using DSQuery and DSGet to get user attributes that are needed to make accounts (not associated with their Windows account). The current command I've got is:

dsquery * -filter "(&(objectCategory=Person)(objectclass=User)(mail=first.last@email.com))" | dsget user -samid -fn -ln -office -email > user.txt

which gets me all the information I need except the domain the user is associated with. There's the attribute in AD called User logon name (pre-Windows 2000) (first box), but as far as I can tell DSGet doesn't return that. I know the DSQuery can get me the groups the user is in but I'm not sure if there's an easy (one-liner) that can get the info needed. Any guidance or help is appreciated.

Josh Brown
  • 47
  • 1
  • 9
  • The domain name (in DNS format) is part of user's DN. Are you looking for anything particular? – raspy Jul 19 '21 at 12:16

1 Answers1

0

There is no attribute User logon name (pre-Windows 2000) in Attribute Editor so there is another way we can get the user logon name using distinguish name (DN) and UPN(User logon Name) enter image description here

please use the below command to get the DN

This is for user

dsquery * -filter "(&(objectCategory=Person)(objectclass=user)(mail=first.last@microsoft.com))" | dsget user "CN=RahulShaw,CN=Users,DC=microsoft,DC=com" -samid -fn -ln -office -email -DN -UPN > Ansuman.txt

enter image description here

This is under Domain Users

dsquery * -filter "(&(objectCategory=Group)(objectclass=group)(mail=first.last@microsoft.com))" | dsget group "CN=Domain Users,CN=Users,DC=microsoft,DC=com" -samid -DN > ipsita.txt

enter image description here

RahulKumarShaw
  • 4,192
  • 2
  • 5
  • 11