Hi All,
I have a requirement to export only active (no disabled users) members of domain local group to csv file. I am trying below vbscript, but facing some issues. Need your assistance to resolve the issue.
Group name: DL_CTX_APPS_TEST . This domain local group is created in abc.us.company.local
Users from different child domains and trusted domain are members of this group.
domain structure:
abc.us.company.local - child domain
pqr.us.company.local - child domain
xyz.us.company.local - child domain
trust.com - one way trusted external domain.
When I run the script, I am getting below error-
DL_CTX_APPS_TEST~Mary Reader~A12345~ABC_COMPANY\A12345~Reader
Mary~Mary_Reader@company.com
DL_CTX_APPS_TEST~Kath Bend~P12345~PQR_COMPANY\P12345~Bend
Kath~Kath_Bend@company.com
DL_CTX_APPS_TEST~Peiming Lius~X12345~XYZ_COMPANY\X12345~Lius
Peiming~Peiming_Lius@eisai.com
D:\test\vb4.vbs<27, 1> Microsoft VBScipt, runtime error: Object doesn't support this property or method: 'AccountDisabled'
If I remove members of trust.com domain (one way trusted external domain) from DL_CTX_APPS_TEST, this script works fine.
Issue is script is able to check whether trusted domain user is active or disabled...
Can someone please assist me?
My Script:
Option Explicit
Dim objTrans, objGroup, objMember, strDN, strNTName, objUAC, strStatus, fs, outFile
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
' Use the NameTranslate object to convert the user DN into
' the user NT name, in the form Domain\sAMAccountName.
Set objTrans = CreateObject("NameTranslate")
Set fs = CreateObject ("Scripting.FileSystemObject")
Set outFile = fs.CreateTextFile ("\\server1\c$\temp\Report.txt")
' Initialize NameTranslate by locating the Global Catalog.
objTrans.Init ADS_NAME_INITTYPE_GC, ""
' Bind to the group object.
Set objGroup = GetObject("LDAP://cn=DL_CTX_APPS_TEST,ou=Groups,dc=abc,dc=us,dc=company,dc=local")
' Enumerate direct members.
For Each objMember In objGroup.Members
'''If objMember.AccountDisabled = TRUE then
If ObjMember.Class = "user" and objMember.AccountDisabled = True Then
'strStatus = "Account Disabled"
Else
If (objMember.Class <> "contact") Then
strDN = objMember.distinguishedName
' Use the Set method to specify the RPC 1779 Distinguished Name.
objTrans.Set ADS_NAME_TYPE_1779, strDN
' Use the Get method to retrieve the NT format name.
strNTName = objTrans.Get(ADS_NAME_TYPE_NT4)
'Wscript.Echo " NT name: " & strNTName
outFile.WriteLine objGroup.sAMAccountName & "~" & objMember.displayName & "~" & objMember.cn & "~" & strNTName & "~" & objMember.sn & " " & objMember.givenName & "~"& objMember.mail
Else
Wscript.Echo " NT name: <contact>"
End If
End If
Next
outFile.Close
Thanks & Best Regards, MPG