Re: Retrieving an object's GUID as a string from Active Directory
- From: "Marty List" <usenet@xxxxxxxxxxxx>
- Date: Thu, 4 Aug 2005 10:52:56 -0600
Your script is using the .objectGUID property, but the example I posted uses the
..GUID property. Also, your script is using "SET =" but that's not necessary
because "The IADs interface converts the GUID from an octet string, as stored on
a directory server, into a string format":
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/iads_property_methods.asp
This is the example script, slightly modified for VBScript. It works for me,
using both global security groups and user accounts:
(Watch for line wraps)
Dim sADsPathObject
Dim sObjectGUID
Dim sBindByGuidStr
Dim IADsObject
Dim IADsObject2
On Error Resume Next
' Query the user for an ADsPath to start.
sADsPathObject = InputBox("This code binds to a directory object by ADsPath,
retrieves the GUID, then rebinds by GUID." & vbCrLf & vbCrLf & "Specify the
ADsPath of the object to bind to :")
If sADsPathObject = "" Then
WScript.Quit
End If
MsgBox "Binding to " & sADsPathObject
' Bind to initial object.
Set IADsObject = GetObject(sADsPathObject)
If (Err.Number <> 0) Then
MsgBox Err.Number & " on GetObject method"
WScript.Quit
End If
' Save the GUID of the object.
sObjectGUID = IADsObject.Guid
MsgBox "The GUID for " & vbCrLf & vbCrLf & sADsPathObject & vbCrLf & vbCrLf & "
is " & vbCrLf & vbCrLf & sObjectGUID
' Release the initial object.
Set IADsObject = Nothing
' Build a string for Binding to the object by GUID.
sBindByGuidStr = "LDAP://<GUID=" & sObjectGUID & ">"
MsgBox sBindByGuidStr
' Bind BACK to the Same object using the GUID.
Set IADsObject = GetObject(sBindByGuidStr)
If (Err.Number <> 0) Then
MsgBox Err.Number & " on GetObject method "
WScript.Quit
End If
MsgBox "Successfully RE bound to " & sADsPathObject & vbCrLf & vbCrLf & " using
the path:" & vbCrLf & vbCrLf & sBindByGuidStr
"Mr K" <MrK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A37F76B2-7199-4EE7-8828-201CB5D2286E@xxxxxxxxxxxxxxxx
> The page you supplied has a VB example but the problem is that things do not
> seem so straight forward with VBScript.
>
> If I run the following script the output is a bunch of question marks...
>
> ADGroup = InputBox("I.E. F00-SQLSERVERENTMGR-2000", "Please enter Active
> Directory group", "F00-SQLSERVERENTMGR-2000")
>
> Set objGroup = GetObject("LDAP://CN=" & ADGroup & ",OU=Applications,OU=Users
> and Groups,DC=f00bar,DC=f00")
>
> WScript.Echo objGroup.objectGUID
> Set GUID = objGroup.objectGUID
.
- References:
- Prev by Date: Simple Scripting Question
- Next by Date: Re: Retrieving an object's GUID as a string from Active Directory
- Previous by thread: Re: Retrieving an object's GUID as a string from Active Directory
- Next by thread: Re: Retrieving an object's GUID as a string from Active Directory
- Index(es):
Relevant Pages
|