If you want to find the guid of current active directory user write the code below to a windows host file and execute it
' NameTranslate constants
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_GUID = 7
' Determine the NetBIOS name of the domain and the NT name of the current user.
Set objNet = WScript.CreateObject("WScript.Network")
strNT4Name = objNet.UserDomain & "\" & objNet.UserName
' Use the NameTranslate object to convert the NT user name to the GUID
Set objNameTranslate = WScript.CreateObject("NameTranslate")
' Initialize NameTranslate by locating the Global Catalog.
objNameTranslate.Init ADS_NAME_INITTYPE_GC, ""
' Use the Set method to specify the NT format of the object name.
objNameTranslate.Set ADS_NAME_TYPE_NT4, strNT4Name
' Use the Get method to retrieve the GUID string.
WScript.Echo objNameTranslate.Get(ADS_NAME_TYPE_GUID)
No comments:
Post a Comment