Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Frustrating ADSI

Reply
 
Old 02-11-2007   #1 (permalink)
Stephan Winkler


 
 

Frustrating ADSI

Hello NG,

Hello NG,

i want to enable a user account.

<snipp>
$user = [ADSI]"LDAP://cn=testaccount,ou=testou,dc=test,dc=com"

this fails

$user.psbase.invokeset("AccountDisabled",$false)
$user.psbase.commitchanges()

Why does it fail?

--
bye

Stefan

My System SpecsSystem Spec
Old 02-11-2007   #2 (permalink)
$hay


 
 

Re: Frustrating ADSI

$usr.userAccountControl=66050 # disable
$usr.userAccountControl=66048 # enable
$usr.setinfo()


--
$hay
http://scriptolog.blogspot.com



"Stephan Winkler" <spamme@ifyoucan.de> wrote in message
news:b4nus219nn32gecfb4k7rvpool4j3ip6ir@4ax.com...
> Hello NG,
>
> Hello NG,
>
> i want to enable a user account.
>
> <snipp>
> $user = [ADSI]"LDAP://cn=testaccount,ou=testou,dc=test,dc=com"
>
> this fails
>
> $user.psbase.invokeset("AccountDisabled",$false)
> $user.psbase.commitchanges()
>
> Why does it fail?
>
> --
> bye
>
> Stefan



My System SpecsSystem Spec
Old 02-11-2007   #3 (permalink)
Stephan Winkler


 
 

Re: Frustrating ADSI

Hello,

>$usr.userAccountControl=66050 # disable
>$usr.userAccountControl=66048 # enable
>$usr.setinfo()


thanks for the hint but as i remember this attribute is cumulated and
have a lot of values. Normally the value 512 is a normal user account
and 514 disables it. I thougt i can use "AccountDisabled",$false to
enable it.

i solved it so:

$user = new-object
system.directoryservices.directoryentry("LDAP://cn=testaccount,ou=testou,dc=test,dc=com")

$user.psbase.invokeset("accountdisabled",$false)
$user.setinfo()

but i dont understand why the commandline in my previous posting won´t
work. :-(

bye

Stephan
My System SpecsSystem Spec
Old 02-11-2007   #4 (permalink)
$hay


 
 

Re: Frustrating ADSI

I think the commitchanges() is the problem
Can't really tell, I'm at home with no AD around

--
$hay
http://scriptolog.blogspot.com



"Stephan Winkler" <spamme@ifyoucan.de> wrote in message
news:s6pus2tn1eknbjtej2v5t5v7b4bpeq8mqr@4ax.com...
> Hello,
>
>>$usr.userAccountControl=66050 # disable
>>$usr.userAccountControl=66048 # enable
>>$usr.setinfo()

>
> thanks for the hint but as i remember this attribute is cumulated and
> have a lot of values. Normally the value 512 is a normal user account
> and 514 disables it. I thougt i can use "AccountDisabled",$false to
> enable it.
>
> i solved it so:
>
> $user = new-object
> system.directoryservices.directoryentry("LDAP://cn=testaccount,ou=testou,dc=test,dc=com")
>
> $user.psbase.invokeset("accountdisabled",$false)
> $user.setinfo()
>
> but i dont understand why the commandline in my previous posting won´t
> work. :-(
>
> bye
>
> Stephan



My System SpecsSystem Spec
Old 02-11-2007   #5 (permalink)
Stephan Winkler


 
 

Re: Frustrating ADSI

Hello,

On Sun, 11 Feb 2007 21:03:25 +0200, "$hay" <no@addre.ss> wrote:

>I think the commitchanges() is the problem
>Can't really tell, I'm at home with no AD around


i tried it with $user.psbase.commitchanges() and with $user.setinfo().
On both versions i had the same behaviour.

bye

Stephan
My System SpecsSystem Spec
Old 02-11-2007   #6 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

Re: Frustrating ADSI

Strange did work before
http://mow001.blogspot.com/2006/07/p...ry-part-3.html
PoSH>$user.InvokeGet('AccountDisabled')
True
PoSH>$user.userAccountControl
546
PoSH>$mow.invokeSet('Accountdisabled',$false)
PoSH>$mow.CommitChanges()
PoSH>$mow.userAccountControl
544

both methods should work,
will do some testing here tomorow

Greetings /\/\o\/\/

"$hay" <no@addre.ss> wrote in message
news:Oc3bX9gTHHA.1228@TK2MSFTNGP06.phx.gbl...
>I think the commitchanges() is the problem
> Can't really tell, I'm at home with no AD around
>
> --
> $hay
> http://scriptolog.blogspot.com
>
>
>
> "Stephan Winkler" <spamme@ifyoucan.de> wrote in message
> news:s6pus2tn1eknbjtej2v5t5v7b4bpeq8mqr@4ax.com...
>> Hello,
>>
>>>$usr.userAccountControl=66050 # disable
>>>$usr.userAccountControl=66048 # enable
>>>$usr.setinfo()

>>
>> thanks for the hint but as i remember this attribute is cumulated and
>> have a lot of values. Normally the value 512 is a normal user account
>> and 514 disables it. I thougt i can use "AccountDisabled",$false to
>> enable it.
>>
>> i solved it so:
>>
>> $user = new-object
>> system.directoryservices.directoryentry("LDAP://cn=testaccount,ou=testou,dc=test,dc=com")
>>
>> $user.psbase.invokeset("accountdisabled",$false)
>> $user.setinfo()
>>
>> but i dont understand why the commandline in my previous posting won´t
>> work. :-(
>>
>> bye
>>
>> Stephan

>
>


My System SpecsSystem Spec
Old 02-11-2007   #7 (permalink)
Gaurhoth


 
 

Re: Frustrating ADSI

66050 and 66048 also set the "Password Does Not Expire" flag.

If you want to enable the account without setting the "password does not
expire flag" use 512 and to disable use 514.

gaurhoth

"$hay" <no@addre.ss> wrote in message
news:%23gRUvrgTHHA.3440@TK2MSFTNGP03.phx.gbl...
> $usr.userAccountControl=66050 # disable
> $usr.userAccountControl=66048 # enable
> $usr.setinfo()
>
>
> --
> $hay
> http://scriptolog.blogspot.com
>
>
>
> "Stephan Winkler" <spamme@ifyoucan.de> wrote in message
> news:b4nus219nn32gecfb4k7rvpool4j3ip6ir@4ax.com...
>> Hello NG,
>>
>> Hello NG,
>>
>> i want to enable a user account.
>>
>> <snipp>
>> $user = [ADSI]"LDAP://cn=testaccount,ou=testou,dc=test,dc=com"
>>
>> this fails
>>
>> $user.psbase.invokeset("AccountDisabled",$false)
>> $user.psbase.commitchanges()
>>
>> Why does it fail?
>>
>> --
>> bye
>>
>> Stefan

>
>


My System SpecsSystem Spec
Old 02-11-2007   #8 (permalink)
RichS


 
 

Re: Frustrating ADSI

If you use the [ADSI] constructor then you get access to the COM methods
rather than the .net methods in which case you need to use SetInfo rather
than CommitChange() -- all very confusing

Using psbase gets access to the underlying objects's methods

--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"$hay" wrote:

> I think the commitchanges() is the problem
> Can't really tell, I'm at home with no AD around
>
> --
> $hay
> http://scriptolog.blogspot.com
>
>
>
> "Stephan Winkler" <spamme@ifyoucan.de> wrote in message
> news:s6pus2tn1eknbjtej2v5t5v7b4bpeq8mqr@4ax.com...
> > Hello,
> >
> >>$usr.userAccountControl=66050 # disable
> >>$usr.userAccountControl=66048 # enable
> >>$usr.setinfo()

> >
> > thanks for the hint but as i remember this attribute is cumulated and
> > have a lot of values. Normally the value 512 is a normal user account
> > and 514 disables it. I thougt i can use "AccountDisabled",$false to
> > enable it.
> >
> > i solved it so:
> >
> > $user = new-object
> > system.directoryservices.directoryentry("LDAP://cn=testaccount,ou=testou,dc=test,dc=com")
> >
> > $user.psbase.invokeset("accountdisabled",$false)
> > $user.setinfo()
> >
> > but i dont understand why the commandline in my previous posting won´t
> > work. :-(
> >
> > bye
> >
> > Stephan

>
>
>

My System SpecsSystem Spec
Old 02-11-2007   #9 (permalink)
Al Dunbar [MS-MVP]


 
 

Re: Frustrating ADSI

wouldn't a better solution be to get the current value, use boolean
operations to set or reset bit 2, and then store the result back?

/Al

"Gaurhoth" <gaurhoth@live.com> wrote in message
news:A0680645-1453-4453-8B93-C3F85B8E2E31@microsoft.com...
> 66050 and 66048 also set the "Password Does Not Expire" flag.
>
> If you want to enable the account without setting the "password does not
> expire flag" use 512 and to disable use 514.
>
> gaurhoth
>
> "$hay" <no@addre.ss> wrote in message
> news:%23gRUvrgTHHA.3440@TK2MSFTNGP03.phx.gbl...
> > $usr.userAccountControl=66050 # disable
> > $usr.userAccountControl=66048 # enable
> > $usr.setinfo()
> >
> >
> > --
> > $hay
> > http://scriptolog.blogspot.com
> >
> >
> >
> > "Stephan Winkler" <spamme@ifyoucan.de> wrote in message
> > news:b4nus219nn32gecfb4k7rvpool4j3ip6ir@4ax.com...
> >> Hello NG,
> >>
> >> Hello NG,
> >>
> >> i want to enable a user account.
> >>
> >> <snipp>
> >> $user = [ADSI]"LDAP://cn=testaccount,ou=testou,dc=test,dc=com"
> >>
> >> this fails
> >>
> >> $user.psbase.invokeset("AccountDisabled",$false)
> >> $user.psbase.commitchanges()
> >>
> >> Why does it fail?
> >>
> >> --
> >> bye
> >>
> >> Stefan

> >
> >

>



My System SpecsSystem Spec
Old 02-12-2007   #10 (permalink)
Gaurhoth


 
 

Re: Frustrating ADSI

Of course you are right. I'm generally only setting the UserAccountControl
value on new accounts I've created, so that didn't occur to me.

gaurhoth

"Al Dunbar [MS-MVP]" <alan-no-drub-spam@hotmail.com> wrote in message
news:OHBOeGjTHHA.5016@TK2MSFTNGP05.phx.gbl...
> wouldn't a better solution be to get the current value, use boolean
> operations to set or reset bit 2, and then store the result back?
>
> /Al
>
> "Gaurhoth" <gaurhoth@live.com> wrote in message
> news:A0680645-1453-4453-8B93-C3F85B8E2E31@microsoft.com...
>> 66050 and 66048 also set the "Password Does Not Expire" flag.
>>
>> If you want to enable the account without setting the "password does not
>> expire flag" use 512 and to disable use 514.
>>
>> gaurhoth
>>
>> "$hay" <no@addre.ss> wrote in message
>> news:%23gRUvrgTHHA.3440@TK2MSFTNGP03.phx.gbl...
>> > $usr.userAccountControl=66050 # disable
>> > $usr.userAccountControl=66048 # enable
>> > $usr.setinfo()
>> >
>> >
>> > --
>> > $hay
>> > http://scriptolog.blogspot.com
>> >
>> >
>> >
>> > "Stephan Winkler" <spamme@ifyoucan.de> wrote in message
>> > news:b4nus219nn32gecfb4k7rvpool4j3ip6ir@4ax.com...
>> >> Hello NG,
>> >>
>> >> Hello NG,
>> >>
>> >> i want to enable a user account.
>> >>
>> >> <snipp>
>> >> $user = [ADSI]"LDAP://cn=testaccount,ou=testou,dc=test,dc=com"
>> >>
>> >> this fails
>> >>
>> >> $user.psbase.invokeset("AccountDisabled",$false)
>> >> $user.psbase.commitchanges()
>> >>
>> >> Why does it fail?
>> >>
>> >> --
>> >> bye
>> >>
>> >> Stefan
>> >
>> >

>>

>
>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Frustrating time with WLM Live Mail
So frustrating Chillout Room
Frustrating time trying to sign in here Vista security
Please Help!!!! Vista Permissions very frustrating! Vista security
THAT FRUSTRATING RED X Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46