[MSH] accesing IADsLargeInteger

98 weergaven
Naar het eerste ongelezen bericht

/\/\o\/\/ [MVP]

ongelezen,
6 jan. 2006 05:45:0206-01-2006
aan
If I get the lastLogon property of an AD user in MSH, I "should" get a
IADsLargeInteger (int64) back, I know how to resolve this value.

only in MSH I get a System.__ComObject back,

MSH H:\> $de.get_Properties().lastLogon | gm


TypeName: System.__ComObject

Name MemberType Definition
---- ---------- ----------
CreateObjRef Method System.Runtime.Remoting.ObjRef
CreateObjRef(Type requestedType)
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
ToString Method System.String ToString()

How can I access the IADsLargeInteger value in MSH ?

or is this solved with the better COM support in Beta 3 ?

gr /\/\o\/\/

Keith Hill [MVP]

ongelezen,
6 jan. 2006 11:46:2406-01-2006
aan
"/\/\o\/\/ [MVP]" <oM...@discussions.microsoft.com> wrote in message
news:AD37E9A4-331D-492A...@microsoft.com...

> How can I access the IADsLargeInteger value in MSH ?
>
> or is this solved with the better COM support in Beta 3 ?

If you have access to the .NET SDK for VS 2005 you can run tlbimp on the COM
DLL to generate an interop assembly. Load that interop assembly into MSH
and then try to type cast the System.__ComObject to the fully qualified type
name for IADsLargeInteger.

--
Keith


/\/\o\/\/ [MVP]

ongelezen,
6 jan. 2006 12:40:4906-01-2006
aan
thx,

I did play with the ADSI interop Type library (generated from VS)
before, did not realy work for me then (don't remember excatly why).

did you work with it already ?

but as the COM support in V3 should be better,
I hoped on an positive aswer on the second question ;-)

as it's just a COM object after all.

MSH>$li = new-object -com LargeInteger
MSH>$li | gm


TypeName: System.__ComObject


if not I will look into it again.

but I think this is an important ComObject to support.
as there are more LargeIntegers in AD (also the replicated LogonTimeStamp)

or maybe the ADSI type library could be embedded in MSH or a CMDlet.?

but atleast the InvokeGet Method is public now in .NET 2.0 (not as MSDN2
stated new ;-)) that helps a lot getting ADSI only properties.


gr /\/\o\/\/


Keith Hill

ongelezen,
6 jan. 2006 16:19:1806-01-2006
aan
"/\/\o\/\/ [MVP]" <n...@Spam.mow> wrote in message
news:O%23CSHjuE...@TK2MSFTNGP11.phx.gbl...

> as it's just a COM object after all.

The problem is (I believe) that since MSH relies on Reflection for late
binding it can't work with System.__ComObject because there is no reflection
info available on the IADsLargeInteger members. If you try to get a
property on the resulting object (skipping the get-member) does it work?

--
Keith

/\/\o\/\/ [MVP]

ongelezen,
6 jan. 2006 17:18:5306-01-2006
aan
nope,

MSH>$li.get_LowPart()
Method invocation failed because [System.__ComObject] doesn't contain a
method named 'get_LowPart'.
At line:1 char:16
+ $li.get_LowPart( <<<< )

gr /\/\o\/\/

Keith Hill

ongelezen,
6 jan. 2006 19:13:4306-01-2006
aan
"/\/\o\/\/ [MVP]" <n...@Spam.mow> wrote in message
news:u29Cg%23wEGH...@TK2MSFTNGP11.phx.gbl...

> nope,
>
> MSH>$li.get_LowPart()
> Method invocation failed because [System.__ComObject] doesn't contain a
> method named 'get_LowPart'.
> At line:1 char:16
> + $li.get_LowPart( <<<< )

Yep I'd say that confirms my theory. It should work by using an interop
assembly though. If you use the interop assembly don't use the "-com"
option on new-object. With interop assemblies your are using .NET objects
and .NET interop takes care of the communication between .NET and COM.

--
Keith


Arul Kumaravel [MSFT]

ongelezen,
10 jan. 2006 12:56:4610-01-2006
aan
MSH Com support is limited to those objects that implement type library
information. if the object doesn't provide type information then we will
not able to make calls into the COM object.

Please share the script and I can try it out and let you know the details.

--
Arul Kumaravel [MSFT]
Development Lead,
Microsoft Command Shell Development,
Microsoft Corporation


This posting is provided "AS IS" with no warranties, and confers no rights


"/\/\o\/\/ [MVP]" <oM...@discussions.microsoft.com> wrote in message
news:AD37E9A4-331D-492A...@microsoft.com...

/\/\o\/\/ [MVP]

ongelezen,
10 jan. 2006 13:55:5210-01-2006
aan
Arul Kumaravel [MSFT] wrote:
> MSH Com support is limited to those objects that implement type library
> information. if the object doesn't provide type information then we will
> not able to make calls into the COM object.
>
> Please share the script and I can try it out and let you know the details.
>


thanks,

there is not much more in the script :

# take a userObject from AD

$de = new-object System.DirectoryServices.DirectoryEntry("LDAP//..etc")

$li = $de.get_Properties().lastLogon
(or the InvokeGet("lastlogon")

or you can just "Dim" one :


MSH>$li = new-object -com LargeInteger

MSH>$li | gm


TypeName: System.__ComObject

Name MemberType Definition
---- ---------- ----------
CreateObjRef Method System.Runtime.Remoting.ObjRef

Equals Method System.Boolean Equals(Object o


GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeServi

GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object InitializeLifeti

ToString Method System.String ToString()

I need the Method like this :

MSH>$li.get_LowPart()
> Method invocation failed because [System.__ComObject] doesn't contain a
> method named 'get_LowPart'.
> At line:1 char:16

to translate the Int64 to a date.

I still need to test with the interop,

but as this are properties much needed when working with AD in a script
(also logontimestamp, but you can get that property with a
ManagementObjectSeacher) it would be handy for MSH to include them
standard someway.

/\/\o\/\/ [MVP]

ongelezen,
11 jan. 2006 14:32:1411-01-2006
aan
I did some more testing on Beta 3, but can not get it working.

I created an TypeLibrary (by loading the ActiveDS.dll as reference in C#
2005 express, and copy the generated file to the Monad dir)

I Loaded it

MSH>[System.Reflection.Assembly]::LoadFile("$MowMsh\Interop.ActiveDs.dll")

GAC Version Location
--- ------- --------
False v2.0.50727 g:\MowSH\Interop.ActiveDs.dll

I think here I did go wrong at first try 3 months ago

MSH>[ActiveDs.IADsLargeInteger]

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False IADsLargeInteger

with reflector I did find out :

MSH>$li = new ActiveDs.LargeIntegerclass
MSH>$li

HighPart
LowPart
--------
-------
0
0

But ..

how to get the Com-Object casted now ?

(I use PwdLastSet now because I use Adam for testing it is
127770055020000000 )

$li = $mow.get_Properties().pwdlastset


MSH>$li

MSH>$li | gm


TypeName: System.__ComObject

Name MemberType Definition
---- ---------- ----------
CreateObjRef Method System.Runtime.Remoting.ObjRef

CreateObjRef(Type requestedType)
Equals Method System.Boolean Equals(Object obj)

GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()


GetType Method System.Type GetType()
InitializeLifetimeService Method System.Object

InitializeLifetimeService()
ToString Method System.String ToString()


MSH>$test = [ActiveDs.LargeIntegerclass]$li
Cannot convert "System.DirectoryServices.PropertyValueCollection" to
"ActiveDs.LargeIntegerClass".
At line:1 char:39
+ $test = [ActiveDs.LargeIntegerclass]$li <<<<
MSH>$test = [ActiveDs.LargeIntegerclass]$li[0]
Cannot convert "System.__ComObject" to "ActiveDs.LargeIntegerClass".
At line:1 char:41
+ $test = [ActiveDs.LargeIntegerclass]$li[0 <<<< ]
MSH>$li[0]

I tryed a lot more combinations but can not seem to get it working.


gr /\/\o\/\/

PS my MSH shows "C:\" (CMD icon) in the Taskbar now (after upgrade) its
confusing while pasting (I will get it fixed LOL)

/\/\o\/\/ [MVP]

ongelezen,
20 jan. 2006 19:48:0720-01-2006
aan
I made a MSH snap-in to get this working,

http://mow001.blogspot.com/2006/01/msh-snap-in-to-translate.html

now I can do it like this :

MSH>add-mshsnapin getIADsLargeInteger
MSH>
MSH>$de = New
System.directoryservices.DirectoryEntry("LDAP://localhost:389/cn=mow,ou=mowOu,dc=mow,dc=adam")
MSH>$li = $de.get_Properties()["pwdlastset"].Value
MSH>Get-IADsLargeInteger $li
127770055020000000
MSH>$long = Get-IADsLargeInteger $li
MSH>[datetime]::FromFileTime($long)

maandag 21 november 2005 1:11:42


but it still would be nice to know why this does not work from MSH,

>> Arul Kumaravel [MSFT] wrote:
>>
>>> MSH Com support is limited to those objects that implement type
>>> library information. if the object doesn't provide type information
>>> then we will not able to make calls into the COM object.
>>>
>>> Please share the script and I can try it out and let you know the
>>> details.

did you find anything yet ?

gr /\/\o\/\/

Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten