Page 1 of 2 12>
Topic Options
#61721 - 2001-12-29 03:39 PM Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
I want to Disable/able account on specific domain, I tried (Netdom.exe, Addusers.exe & Net User.exe) these command Disabled/able the account on the local workstation but it didn’t on the domain.

Please help.

Top
#61722 - 2001-12-29 04:48 PM Re: Disable account
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
attiahia

you might want to try a couple of alternatives:

cusrmgr.exe from the Win2k resource kit can do this. Here's a link:

CUSRMGR SYNTAX

Check out the SetProperties Functions and the +s Property switch ...

2) ADSI can do this as well. All you'd need is a Windows 2000 workstation for that ... think there are even examples on da-board here ... let us know if you want to pursue this course of action ...

-Shawn

Top
#61723 - 2001-12-30 07:08 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
I highly appreciate your help.
I like to work with cusrmgr.exe and here is the case.

We have domain called “ABC” , as the domain LAN administrator told me that active directory installed on this domain and he placed my account on a specific group has admin privilege over all this domain.

In addition he added my account to the domain controller of this domain

Now, I logged on to this domain & did the following (in DOS mood).

CUSRMGR –u Test1 +s AccountDisabled –m domain controller name

Then I am getting “CUsrMgr Ver 1.0 jan98 by G.Zanzen © MCS central Europe)

After this I logged to the domain with Test1 account and it worked & it logged me in while it shouldn’t.

Thank you.

[ 30 December 2001: Message edited by: attiahia ]

Top
#61724 - 2001-12-30 10:14 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
Shawn.
Since AD is installed on this domain I think I should use ADSI. By searching in the board I found piece of code done by you (OU BAD BOYS)and I think it’s answer 80% of what I need. http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=1&t=002588


I still need your help please.

Please excuse me if the following questions seem to you silly, I am totally new to AD & I didn’t tack any course about it.

The user who I want to disable/enable his account is in the following path (I got this path from the domain LAN administrator)

LDAP://ABCD-00730-nd05.zain.com/CN=noor NIaa.,OU=Test,OU=Messaging,DC=zain,DC=com

My question are:
In $sysinfo = createobject("adsysteminfo")

Should I put this path as ("adsysteminfo") ?

How can I get this path through the script? I mean can I search for it if I have only the users account which I want to disable his account?

In $user = getobject("LDAP://"+$sysinfo.username)
Should I place the user account in username?
Thank you.

Top
#61725 - 2001-12-30 01:53 PM Re: Disable account
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
attiahia,
no silly question here, only someone who is seeking for knowledge
Nothing in the Shawn's example have to be changed.

For the following line :
$sysinfo = createobject("adsysteminfo")
Adsysteminfo is an AD object. It's the name you have to use to call it.
$Sysinfo is a handle to adsysteminfo (in fact, a clone of it, as you'll never be allowed by the system to get your hand on the orignal object, only a memory copy stored in a variable)
The Adsysteminfo object has multiple properties and method. They are called like this :
$Object_Handle.property
$Object_Handle.method("parameters")
Actually, the most used properties are :
.Username
.Computername
.GetAnyDC (not really sure of the correct syntax)

Beware, ADsysteminfo isd dependant of the current user on the current workstation.
The respective values will be different with another user or computer

.Username will return the following value :
CN=Current User Name,OU=Test,OU=Messaging,DC=zain,DC=com

.Computername will return the following value :
CN=Current Computer Name,OU=Test,DC=zain,DC=com
(all are examples, of course)

For $user = getobject("LDAP://"+$sysinfo.username)
In fact, this is exactly the same :
$user = getobject("LDAP://CN=Current User Name,OU=Test,OU=Messaging,DC=zain,DC=com")

The $User variable will be the current user, but as an object, so with methods and properties. In your case, the user object we'll get have the AccountDisable property.

Everything you need, no ?
And as i don't think you'll do this with the user code and password you want to disable, here's what you need
a copy/paste will be enough :

code:

$user = GetObject("LDAP:// CN=noor NIaa.,OU=Test,OU=Messaging,DC=zain,DC=com")
$user.AccountDisabled = 1 ;disabled the account
$user.SetInfo ; Needed to update the new informations


after, only have to wait the time AD Server will take to replicate the change

[ 30 December 2001: Message edited by: Alex.H ]

_________________________
? getobject(Kixtart.org.Signature)

Top
#61726 - 2001-12-31 09:37 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
Thank you a lot, I got some error & have some questions (There is no much examples about crateobject function in the board ).

Following is what I did.
As I told you that The user who I want to disable/enable his account is in the following path (I got this path from the domain LAN administrator) LDAP://ABCD-00730-nd05.zain.com/CN=noor NIaa.,OU=Test,OU=Messaging,DC=zain,DC=com

$sysinfo = createobject("adsysteminfo")
$user = getobjec("LDAP://"+$sysinfo.username)
do I have to insert ABCD-00730-nd05.zain.com after LDAP:// ?

You said that .Username (property) will return current user name, actually I have a list of users accounts who I want to disable their accounts. My script is reading these account one by one and then I want to pass it to the disable/enable command. Should I search for each account in AD data base to get the path then disable/enable it?


I got this error “;Script error : unknown command !$user.AccountDisabled = 1”


How can I know the AD objects and properties for each abject? I searched in MSDN (msdn.microsoft.com/library) for ADO programmers guide, object model & reference and all what I found was about ActiveX.

Your support is highly appreciated.

Top
#61727 - 2001-12-31 10:00 AM Re: Disable account
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
What happens if you run this:


break on

$sysinfo = createobject("adsysteminfo")
if $sysinfo
?"username=" $sysinfo.username
?"@SERROR"
endif

exit 1

-Shawn

Top
#61728 - 2001-12-31 10:23 AM Re: Disable account
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
atti,
I searched one place for you from msdn.
it's for scripting ActiveDirectoryServiceInterface. check it out at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netdi r/adsi/adsi_scripting_tutorial.asp
_________________________
!

download KiXnet

Top
#61729 - 2001-12-31 10:26 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
SHAWN.
I got my account data.
username=CN=Attiah\, Ibrahim A,OU=AD Administrative Accounts,OU=Messaging,DC=aramco,DC=com

[ 31 December 2001: Message edited by: attiahia ]

Top
#61730 - 2001-12-31 10:34 AM Re: Disable account
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
how about this:


break on


$user = GetObject("LDAP://CN=noor NIaa.,OU=Test,OU=Messaging,DC=zain,DC=com")
if $user
?"setting info..."
$user.AccountDisabled = 1 ; disabled the account
?"@ERROR: @SERROR"
$user.SetInfo ; Needed to update the new informations
?"@ERROR: @SERROR"
else
?"@ERROR ; @SERROR"
endif


exit 1

What you get when you run this ?

-Shawn

[ 31 December 2001: Message edited by: Shawn ]

Top
#61731 - 2002-01-01 12:04 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
- I got operation completed successfully, but after this I logged off & logged on with noor account and it worked (logged on to the domain)
- How can I get the user path ://CN=noor NIaa.,OU=Test,OU=Messaging,DC=zain,DC=com
- Can I place $userId (which I read through the script from all domain users TXT file) in CN=noor NIaa. to be CN=$userId.

Thanks a lot.

Top
#61732 - 2001-12-31 01:48 PM Re: Disable account
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
attiahia,
You should get a look here : ADSearch() UDF

It's all you need now to get complete LDAP context name of a given user name from any computer in your office
Beware, only * can be use as wildcard, nothing else
The little thing to do after is to remove
",AccountName=...,IsContainer=0,IsGroup=0" and you have everything to do a getobject("LDAP://" ...)
You can directly do this in the udf. Remove the lines after the comment "; To get rid of " LDAP://" adding the informations relative to ",AccountName=*", ",IsContainer=*" and ",IsGroup=*"


- Shawn,
Finally, it was a good idea to convert 3 vbscript and mix them in one UDF

[ 31 December 2001: Message edited by: Alex.H ]

_________________________
? getobject(Kixtart.org.Signature)

Top
#61733 - 2002-01-03 12:18 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
I went through ADsearch function and the additional very useful example which I received from Alex.H and for the time being I know that $user.AccountDisabled=1 will disable the account, how can I enable the account again?

Also how can I find all AD objects and properties, method for each object.

Thank you.

Alex.H
The example which I received from you (via e-mail) was useful for me and I sent you some questions about it, please let me know if you did not receive it or you want me to place the same questions here in the board.

Thank you.

Top
#61734 - 2002-01-03 12:38 AM Re: Disable account
Anonymous
Unregistered


hi attiahia,

speaking from gained registry knowledge i would expect that replacing the 1 with a 0 would do the trick

but that is just a lucky quess

Alex T

[ 02 January 2002: Message edited by: Ch3lsea ]

Top
#61735 - 2002-01-02 02:19 PM Re: Disable account
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
attiahia ,
You should post it on the board, as it may help other user here. For now, i don't have access to my home mail, so i'll see it this evening.
also, Ch3lsea is right : $user.AccountDisabled=0 enable the user with removing the flag "Disabled"

For informations about users and other AD objects: http://msdn.microsoft.com/library/en-us/netdir/adsi/persistent_object_interfaces.asp

[ 02 January 2002: Message edited by: Alex.H ]

_________________________
? getobject(Kixtart.org.Signature)

Top
#61736 - 2002-01-02 08:35 PM Re: Disable account
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
Some of you may thing this interesting to understand the multiples objects I used in the ADSearch UDF : http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000115 (in the reply to the UDF)
_________________________
? getobject(Kixtart.org.Signature)

Top
#61737 - 2002-01-16 10:23 AM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
Alex.H & Shawn

I used your function/code to disable/enable the user e-mail account on domain has active directory and it worked excellence.

Can I use the same code to disable/enable the user internet account?

The domain administrator told me that internet accounts are authenticated from database deferent than the e-mail users data base.

Thank you.

[ 16 January 2002: Message edited by: attiahia ]

Top
#61738 - 2002-01-16 01:14 PM Re: Disable account
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
Attiahia,
Did you say different ?
could you explain a little more ? is it a different server with his own database ?
_________________________
? getobject(Kixtart.org.Signature)

Top
#61739 - 2002-01-16 07:33 PM Re: Disable account
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
I hope that I can explain the situation here correctly.

I have a list with 100 users who I want to disable their e-mail account AND their internet account.

what I did was that reading the user from this list and pass it to your function which fined the OU path for it and then disable the account, this part worked excellent.

I thought this part will disable the e-mail account and internet account but it Did Not.

What I understood is that when the user want to log in to the internet, he will be authenticated from deferent LDAP server and I got the name of this server (i.e st8en1.dhw.zain.com.st).

So, In your first code and specifically in the following line:
$AdoCommand.CommandText ="Select AdsPath, samAccountName, GroupType from 'LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")+"' "+$filter

I tried to replace ("LDAP://rootDSE") with ("LDAP://st8en1.dhw.zain.com.st ")
But it seems to me that it did not work.

Please help.

Top
#61740 - 2002-01-16 10:08 PM Re: Disable account
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
You are looking in the right way, just missing a little thing :
it's : 'LDAP://st8en1.dhw.zain.com.st/rootDSE'
This will result in :
Select AdsPath, samAccountName, GroupType from 'LDAP://"+GetObject("LDAP://st8en1.dhw.zain.com.st/rootDSE").Get("defaultNamingContext")+"' "+$filter

In case it's not working (don't see why, but everything can happen), replace "st8en1.dhw.zain.com.st" with the server netbios name.

_________________________
? getobject(Kixtart.org.Signature)

Top
Page 1 of 2 12>


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

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

Generated in 0.078 seconds in which 0.031 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org