if member of group
HejJeg kan ikke lige finde ud af hvor jeg skal ligge en "if member of group" then. henne for at det virker
Dim objFSO, WriteText, strText, strNewText, objFile, objConnection, objCommand, objRecordSet, objUser, strUserDN, strResult, arrProxyAddresses, objMemberOf, strFile, StrGrp, strMail
set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "test.txt"
If objFSO.FileExists("test.txt") Then
objFSO.DeleteFile(strFile)
end if
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"SELECT Name, sAMAccountName, mobile, proxyAddresses, homeDirectory, homeDrive, memberOf, scriptPath, distinguishedName FROM 'LDAP://dc=domæne,dc=local' WHERE objectCategory='Person'"
Set objRecordSet = objCommand.Execute
Set WriteText = objFSO.OpenTextFile("test.txt", 8, true)
objRecordSet.MoveFirst
While Not objRecordSet.EOF
strUserDN = objRecordSet.Fields("distinguishedName")
set objUser = GetObject("LDAP://" & strUserDN)
if objUser.AccountDisabled = FALSE Then
Do Until objRecordSet.EOF
WriteText.WriteLine("Name" & vbTab & vbTab & ":" & objRecordSet.Fields("Name").Value & vbCr)
WriteText.WriteLine("Account" & vbTab & vbTab & ":" & objRecordSet.Fields("sAMAccountName").Value & vbCr)
WriteText.WriteLine("Mobil" & vbTab & ":" & vbCrLf & vbTab & vbTab & ":" & objRecordSet.Fields("mobile").Value & vbCr)
WriteText.WriteLine("Memberships" & vbTab & ":" & vbCr)
arrMemberOf = objRecordSet.Fields("memberOf")
if isArray(objRecordSet.Fields("memberOf")) Then
For Each aMemberOf in arrMemberOf
StrGrp = Right(aMemberOf,Len(aMemberOf)-3)
StrGrp = Left(StrGrp,InStr(StrGrp,",")-1)
WriteText.WriteLine (vbTab & vbTab & ":" & StrGrp & vbCr)
Next
End if
objRecordSet.MoveNext
WriteText.WriteLine
Loop
Else
objRecordSet.MoveNext
End if
wend
WriteText.Close
Set WriteText = NOTHING
Set objFSO= NOTHING
WScript.Echo "Done"