Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

System.DirectoryServices.Protocols

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 06-10-2007   #1 (permalink)
RichS
Guest


 

System.DirectoryServices.Protocols

I am experimenting with PowerShell code to undelete AD tombstoned objects.

I can search, isolate and map an object to a particular deleted object.

I need to use
System.DirectoryServices.Protocols.DirectoryAttributeModification to perform
the undelete. I am having a lot of trouble actually creating an object of
this type. I have already loaded the relevant assembly and have successfuly
created other objects in SDS.Protocols namespace.

Has anyone successfully acheived this and if so how?

Thanks
--
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

My System SpecsSystem Spec
Old 06-13-2007   #2 (permalink)
Marcel J. Ortiz [MSFT]
Guest


 

Re: System.DirectoryServices.Protocols

The reason you are having trouble creating the type is because the assembly
containing it (System.DirectoryServices.Protocols.dll) isn't loaded.

There's a few ways to load an assembly. The easiest is probably just to use
LoadWithPartialName.

[reflection.assembly]::LoadWithPartialName("system.directoryservices.protocols")

However, that is deprecated which means it will probably be removed in the
next version of the framework. You can also use Assembly.LoadFrom or the
community extensions Resolve-Assembly.


"RichS" <RichS@discussions.microsoft.com> wrote in message
news:310F128A-F4BB-4AC6-955C-01A1121B13FE@microsoft.com...
>I am experimenting with PowerShell code to undelete AD tombstoned objects.
>
> I can search, isolate and map an object to a particular deleted object.
>
> I need to use
> System.DirectoryServices.Protocols.DirectoryAttributeModification to
> perform
> the undelete. I am having a lot of trouble actually creating an object of
> this type. I have already loaded the relevant assembly and have
> successfuly
> created other objects in SDS.Protocols namespace.
>
> Has anyone successfully acheived this and if so how?
>
> Thanks
> --
> 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


My System SpecsSystem Spec
Old 06-14-2007   #3 (permalink)
RichS
Guest


 

Re: System.DirectoryServices.Protocols

Thank you for your reply but I am afraid that this is not correct.

I have loaded the assembly and sucessfully created other objects in that
namespace as stated in the original post. I have tried loading the assembly
using LoadWithPartialname and Load and Resolve-Assembly. If I hadn't loaded
the assembly I would have received the error message telling me that the
assembly was not loaded when I tried to create the object.

The issue appears to be around the constructor of the class. Easiest way to
resolve this in the short term is write a cmdlet to perform the modification
I suppose as I have some example code


--
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


"Marcel J. Ortiz [MSFT]" wrote:

> The reason you are having trouble creating the type is because the assembly
> containing it (System.DirectoryServices.Protocols.dll) isn't loaded.
>
> There's a few ways to load an assembly. The easiest is probably just to use
> LoadWithPartialName.
>
> [reflection.assembly]::LoadWithPartialName("system.directoryservices.protocols")
>
> However, that is deprecated which means it will probably be removed in the
> next version of the framework. You can also use Assembly.LoadFrom or the
> community extensions Resolve-Assembly.
>
>
> "RichS" <RichS@discussions.microsoft.com> wrote in message
> news:310F128A-F4BB-4AC6-955C-01A1121B13FE@microsoft.com...
> >I am experimenting with PowerShell code to undelete AD tombstoned objects.
> >
> > I can search, isolate and map an object to a particular deleted object.
> >
> > I need to use
> > System.DirectoryServices.Protocols.DirectoryAttributeModification to
> > perform
> > the undelete. I am having a lot of trouble actually creating an object of
> > this type. I have already loaded the relevant assembly and have
> > successfuly
> > created other objects in SDS.Protocols namespace.
> >
> > Has anyone successfully acheived this and if so how?
> >
> > Thanks
> > --
> > 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

>
>

My System SpecsSystem Spec
Old 06-14-2007   #4 (permalink)
Marcel J. Ortiz [MSFT]
Guest


 

Re: System.DirectoryServices.Protocols

> If I hadn't loaded
> the assembly I would have received the error message telling me that the
> assembly was not loaded when I tried to create the object.


Yes, you didn't mention what error you received.

> The issue appears to be around the constructor of the class. Easiest way
> to
> resolve this in the short term is write a cmdlet to perform the
> modification
> I suppose as I have some example code


Maybe. An easier way would probably be to use System.Activator. However,
you shouldn't be having any trouble creating the object. I can't seem to
repro any error on my machine.

PS D:\>
[reflection.assembly]::LoadWithPartialName("system.directoryservices.protocols")

GAC Version Location
--- ------- --------
True v2.0.50727
C:\Windows\assembly\GAC_MSIL\System.DirectoryServices.Protocols\2.0.0.0__b03f5f7f11d50a3a\Syst...

PS D:\> $a = new-object
System.DirectoryServices.Protocols.DirectoryAttributeModification

PS D:\> get-member -in $a


TypeName:
System.DirectoryServices.Protocols.DirectoryAttributeModification

Name MemberType Definition
---- ---------- ----------
Add Method System.Int32 Add(Byte[] value),
System.Int32 Add(String value), System.Int32 Add...
AddRange Method System.Void AddRange(Object[] values)
Clear Method System.Void Clear()
Contains Method System.Boolean Contains(Object value)
....
....


What error are you getting?


"RichS" <RichS@discussions.microsoft.com> wrote in message
news6C3FDF8-36E7-4F95-A09A-E431923DAB83@microsoft.com...
> Thank you for your reply but I am afraid that this is not correct.
>
> I have loaded the assembly and sucessfully created other objects in that
> namespace as stated in the original post. I have tried loading the
> assembly
> using LoadWithPartialname and Load and Resolve-Assembly. If I hadn't
> loaded
> the assembly I would have received the error message telling me that the
> assembly was not loaded when I tried to create the object.
>
> The issue appears to be around the constructor of the class. Easiest way
> to
> resolve this in the short term is write a cmdlet to perform the
> modification
> I suppose as I have some example code
>
>
> --
> 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
>
>
> "Marcel J. Ortiz [MSFT]" wrote:
>
>> The reason you are having trouble creating the type is because the
>> assembly
>> containing it (System.DirectoryServices.Protocols.dll) isn't loaded.
>>
>> There's a few ways to load an assembly. The easiest is probably just to
>> use
>> LoadWithPartialName.
>>
>> [reflection.assembly]::LoadWithPartialName("system.directoryservices.protocols")
>>
>> However, that is deprecated which means it will probably be removed in
>> the
>> next version of the framework. You can also use Assembly.LoadFrom or the
>> community extensions Resolve-Assembly.
>>
>>
>> "RichS" <RichS@discussions.microsoft.com> wrote in message
>> news:310F128A-F4BB-4AC6-955C-01A1121B13FE@microsoft.com...
>> >I am experimenting with PowerShell code to undelete AD tombstoned
>> >objects.
>> >
>> > I can search, isolate and map an object to a particular deleted object.
>> >
>> > I need to use
>> > System.DirectoryServices.Protocols.DirectoryAttributeModification to
>> > perform
>> > the undelete. I am having a lot of trouble actually creating an object
>> > of
>> > this type. I have already loaded the relevant assembly and have
>> > successfuly
>> > created other objects in SDS.Protocols namespace.
>> >
>> > Has anyone successfully acheived this and if so how?
>> >
>> > Thanks
>> > --
>> > 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

>>
>>


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question when using System.DirectoryServices.DirectoryEntry HolySaphAngel PowerShell 2 07-21-2008 03:44 PM
System.DirectoryServices.DirectoryEntry & the accountExpires property Clint Bergman PowerShell 8 04-30-2007 09:29 AM
System.Directoryservices.Protocols RichS PowerShell 0 03-03-2007 11:51 AM
Protocols Billy Vista networking & sharing 1 02-14-2007 02:35 PM
DirectoryServices.SeachResults - Part 1, Howto? Chris Warwick PowerShell 3 12-06-2006 07:32 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com 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 2005-2008