Pessoal
Tenho um script (código 1) usado para gerar um arquivo com uma lista TXT de usuários do dominio. Esse script faz apenas uma busca simples de usuários com alguns atributos separados por um "|". Mas preciso inserir o codigo 2 para que ele faça uma busca de acordo com o security group a que ele pertence. Por favor, olhem abaixo e vejam se tem como inserir o codigo 2 dentro do código 1.
Obrigado.
CODIGO 1
Dim oContainer
Dim OutPutFile
Dim FileSystem
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("c:\db_ldap.txt", True)
Set oContainer = GetObject("LDAP://OU=Usuarios,DC=dominio,DC=com")
EnumerateUsers oContainer
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Quit(0)
Sub EnumerateUsers(oCont)
Dim oUser, bUser
For Each oUser In oCont
bUser = False
Select Case LCase(oUser.Class)
Case "user"
bUser = True
OutPutFile.Write oUser.sAMAccountName & "|"
OutPutFile.Write oUser.displayName & "|"
OutPutFile.Write oUser.mail & "|"
OutPutFile.Write oUser.physicalDeliveryOfficeName & "|"
OutPutFile.Write oUser.telephoneNumber & "|"
OutPutFile.Write oUser.department & "|"
OutPutFile.Write oUser.title
Case "organizationalunit", "container"
EnumerateUsers oUser
End Select
If bUser Then
OutPutFile.WriteLine
End If
Next
End Sub
CODIGO 2
' descobre qual o grupo UF_ do usuário
For Each strMemberOf in arrMembersOf
strOrgao = ucase( mid( left(strMemberOf,instr (strMemberOf, ",") -1 ), 4 ))
if UF_Valida(strOrgao) then 'procura apenas grupo uf_xxxxx
strOrgao1 = mid(strOrgao,4)
'wscript.echo strorgao
'se o órgão for diretoria, presidencia ou vice-presidencia
cargo = left( lcase( objUser.Title ), 4)
if (strOrgao = "UF_PRESI" and cargo = "pres" ) or _
(strOrgao = "UF_VIPEX" and cargo = "vice" ) or _
(left(strOrgao,5)="UF_DI" and cargo = "dire" ) then
aadm = "S"
end if
if (strOrgao= "UF_OUVID" and cargo = "gere" ) then
aadm = "O"
end if
end if
next
' Pega informações do grupo UF_ encontrado...
if strOrgao1 <> "" then
Set objGroup = GetObject("LDAP://cn=uf_" & strOrgao1 & ",ou=usr_function,ou=grupos,dc=dominio,dc=com")
objGroup.GetInfo
'pega a descrição do órgão e o fax
orgaonac = objGroup.Description
orgaoext = RetornaOrgaoIngles(strorgao1)
tmpfax = objgroup.info
' ...e procura o grupo UF_ do qual este 1º grupo UF_ faz parte
arrMembersOf = objGroup.GetEx("memberOf")
For Each strMemberOf in arrMembersOf
strOrgao = ucase( mid( left(strMemberOf,instr (strMemberOf, ",") -1 ), 4 ))
if UF_Valida(strorgao) then 'procura apenas grupo uf_xxxxx
strOrgao2 = mid(strOrgao,4)
end if
next
end if
' procura o grupo UF_ do qual este 2º grupo UF_ faz parte
if strOrgao2 <> "" then
Set objGroup = GetObject("LDAP://cn=uf_" & strOrgao2 & ",ou=usr_function,ou=grupos,dc=dominio,dc=com")
objGroup.GetInfo
if tmpfax = "" then
tmpfax = objgroup.info
end if
arrMembersOf = objGroup.GetEx("memberOf")
For Each strMemberOf in arrMembersOf
strOrgao = ucase( mid( left(strMemberOf,instr (strMemberOf, ",") -1 ), 4 ))
if UF_Valida(strorgao) then 'procura apenas grupo uf_xxxxx
strOrgao3 = mid(strOrgao,4)
end if
next
end if