JSI Tip 9791. How can I enumerate the user accounts that have a missing attribute?


Using ADFind.exe freeware, I have scripted NoAttr.bat to display the distinguishedName of all users in your domain that do not have an attribute name that you specify.

The syntax for running NoAttr.bat is:

NoAttr AttributeName.

Where AttributeName is the name of the missing attribute, like description or mail.

NoAttr.bat contains:

@echo Off
if \{%1\}==\{\} @echo NoAttr AttributeName&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set attr=%1
set attr=%attr:"=%
set adf=adfind -default -f "&(objectcategory=Person)" %attr% objectCategory
for /f "Skip=3 Tokens=1* Delims=: " %%a in ('%adf%^|find ":"') do (
 set p1=%%a
 set p1x=!p1:^>=!
 if /i "!p1x!" EQU "dn" set dn="%%b"&set OK=N
 if /i "!p1x!" EQU "%attr%" set OK=Y&if "%%b" EQU "" set ON=N
 if /i "!p1x!" EQU "objectCategory" if "!OK!" EQU "N" @echo !dn!
)
endlocal



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish