Page 1 of 1 1
Topic Options
#77578 - 2001-04-11 07:25 PM K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Just testing more of the same and this evolved...

code:

break on


;
; SCANUSER.K2K
;
; This script enumerates all the user account's in your domain and displays
; their status (expired, disabled and locked-out)...
;
; To get a hardcopy, pipe the output to a file like this...
;
; kix32c scanuser.k2k $out=filename.ext
;


$padding = " "


if $out
if exist("$out")
del "$out"
endif
$= redirectoutput("$out")
endif


$domain = getobject("WinNT://@LDOMAIN")


if $domain

$filter = "user",""

$domain.filter = $filter

for each $user in $domain

$status = ""

if $user.accountdisabled
$status = $status + "disabled"
endif

if $user.passwordexpired
if $status
$status=$status+","
endif
$status = "$status"+"expired"
endif

if $user.accountlocked
if $status
$status=$status+","
endif
$status = $status + "locked"
endif

if $status

$username = substr($user.name+$padding,1,32)
? "$username $status"

endif

next

endif

exit


Shawn

*** Important Info

This script runs only on Windows 2000 workstations and servers... but it will enumerate user's in regular old NT4 domains...

Shawn..

[This message has been edited by Shawn (edited 11 April 2001).]

Top
#77579 - 2001-04-11 10:44 PM Re: K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Sorry, let me rephrase that...

Just "playing" with more of the same and this evolved...

Shawn


Top
#77580 - 2001-04-18 02:15 AM Re: K2K/ADSI: User Spotting in your Domain ...
Kyle Offline
Fresh Scripter

Registered: 2000-05-30
Posts: 9
Loc: Irvine,CA USA
Cool! Do you know where I can get a list of available objects?

I'm looking to write a script that will enumerate the MS Exchange distribution list membership.

Thanks,

------------------
Kyle Shaver, MCSE
kyle_shaver@phoenix.com

_________________________
Kyle Shaver, MCSE [url=mailto:kyleshaver@cox.net]kyleshaver@cox.net[/url]

Top
#77581 - 2001-04-18 03:14 AM Re: K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kyle,

Sure thing ... here's an introduction that talks about Exchange 5.5 and ADSI...

Active Directory Service Interfaces Overview

Might want to download the ADSI help files (mid page) from here...

Active Directory Service Interfaces (ADSI) 2.5

In there should be lots of info and examples... might want to also check out MSDN at...

Active Directory Service Interfaces

Shawn.

Top
#77582 - 2001-04-18 04:26 PM Re: K2K/ADSI: User Spotting in your Domain ...
Anonymous
Unregistered


Hey Shawn,

I have been testing a bit on your script and it works perfectly But I have a bit of a problem...When kix "prints" the username on the screen it only prints the first character!!! I experienced the same thing when I extracted data from a database with kix, anybody know what could be wrong?

By the way, I'm using kix2001

------------------
Cheers....

David

Top
#77583 - 2001-04-18 04:37 PM Re: K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
David,

This works on my Win2k box. Are you running Win2K or WinNT with ADSI installed ? Try modifying the print bit like this...

if $status
? $user.name + " $status"
endif

But now that you mention it, I'm surprised that it works for me because I thought we identified this exact problem in an earlier post ?!?!? hmmm, this might be worth investigating.

Shawn.

Top
#77584 - 2001-04-18 05:27 PM Re: K2K/ADSI: User Spotting in your Domain ...
Anonymous
Unregistered


Hey Shawn,

Im running it on my Win95 box with ADSI installed. But I dont think this is related to ADSI, but to the COM/OLE support in Kix, because I got the same problem when communicating with databases. I tried to output in many different ways, with and without brackets, I also tried outputting to a file, but all with the same result. Shawn, do you have a windows 95 you can test this on?

------------------
Cheers....

David

Top
#77585 - 2001-04-18 06:13 PM Re: K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
David:

No, I don't have a Win9x box to test on. I have one at home though, but it's not connected to a network. But I was seeing this problem with IE55 on 9x. I was also getting this error when using ADSI on 2K, but only when embedding OLE assigned variables in a string...

BUG - OLE assigned variables embedded in strings

It would seem that (for some strange reason)this problem is "worse" on 9x !

Shawn.

[This message has been edited by Shawn (edited 18 April 2001).]

Top
#77586 - 2001-04-18 06:58 PM Re: K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
David, you might be on to something here, this just gets stranger and stranger I've found that if you add a null string into the mix, it works on Win2K !

code:

break on


; This script displays your active directory domain name


$domain = getobject("WinNT://@LDOMAIN")


if $domain


?"name=" $domain.name ; <--- this always worked on NT


$name = $domain.name ; <--- assign to variable


?"name=$name" ; <--- this doesn't work ! (as before)


$name = $domain.name+"" ; <--- do same but add null string !


?"domain name=$name" ; <--- and now it works on NT


endif


exit


Shawn.

[This message has been edited by Shawn (edited 19 April 2001).]

Top
#77587 - 2001-04-18 11:56 PM Re: K2K/ADSI: User Spotting in your Domain ...
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Shawn and David,

I have tried retrieving strings from COM-objects in Win95 and Win98, it always failes, returning only the first character off the string.

I just tried the trick of adding a null string, but this dosn't work for Win9x

Erik

Top
#77588 - 2001-04-20 09:42 AM Re: K2K/ADSI: User Spotting in your Domain ...
Anonymous
Unregistered


Ruud,

maybe you have a solution for this? Or maybe you can tell us what we are doing wrong?

------------------
Cheers....

David

Top
#77589 - 2001-04-27 04:28 PM Re: K2K/ADSI: User Spotting in your Domain ...
Anonymous
Unregistered


Could this be adapted to check if users were using 'password' as their password?

We recently merged several domains into one and had a problem with WINS that prevented users changing their passwords - I'd like to capture all the lazy ones and force them to change at next logon.

Any other ideas out their?


Top
#77590 - 2001-04-27 09:14 PM Re: K2K/ADSI: User Spotting in your Domain ...
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
David:

No - unfortunately (or fortunately, depending on your point of view), one can't fetch the user password in plain-text (can't fetch it encrypted either). This is probably a good thing anyway. The most one can do with these functions is to programmatically set the user's password. Or if running under a non-admin account, set the password if you know the old password.

st

Top
#77591 - 2001-05-19 07:48 PM Re: K2K/ADSI: User Spotting in your Domain ...
creutz Offline
Fresh Scripter

Registered: 2000-06-14
Posts: 32
Loc: Helsinki, Finland
has anybody succeeded with Class computer i.e. has anybody been able to enumerate the domian computers and getting more than one charater from the name
creutz

Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 874 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.064 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.