none
Localizar Usuario en DC RRS feed

Respuestas

  •  

     

    Code Snippet

    Const ADS_SCOPE_SUBTREE = 2

    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection

    FindUser = InputBox("Please Enter A UserName", "Find User OU")
    If FindUser = "" Then
    MsgBox("No UserName Was Added")
    WScript.Quit
    Else
    strUser = FindUser
    End If

    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    objCommand.CommandText = _
        "SELECT distinguishedName FROM 'LDAP://dc=xxxxx,dc=yyy'WHERE objectCategory='user'AND sAMAccountName='" & strUser & "'"
    Set objRecordSet = objCommand.Execute

    objRecordSet.MoveFirst
    Do Until objRecordSet.EOF
        strDN = objRecordSet.Fields("distinguishedName").Value
        arrPath = Split(strDN, ",")
        intLength = Len(arrPath(1))
        intNameLength = intLength - 3
        Wscript.Echo strUser & " --> " & Right(arrPath(1), intNameLength)
        objRecordSet.MoveNext
    Loop

     

     

     

     

    jueves, 31 de enero de 2008 13:12
  • Puedes utilizar un query en el Active Directory y luego ver las propiedades del usuario.

    Using Saved Queries http://technet2.microsoft.com/WindowsServer/en/library/075c22c0-6204-441b-9ee9-fa0ccbc0ca1e1033.mspx


    Slds
    Sebastian del Rio

    jueves, 31 de enero de 2008 14:10
    Moderador

Todas las respuestas

  •  

    Con esto obtienes un listado en unr archivo csv de usuarios y su respectiva OU

     

     

    Code Snippet

    Set objExplorer = CreateObject("InternetExplorer.Application")
    objExplorer.Navigate "about:blank"
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Width = 400
    objExplorer.Height = 200
    objExplorer.Left = 0
    objExplorer.Top = 0
    objExplorer.Visible = 1

    Do While (objExplorer.Busy)
    Loop

    Set objDocument = objExplorer.Document
    objDocument.Open
    objDocument.Writeln "<html><head><title>Service Status</title></head>"
    objDocument.Writeln "<body bgcolor='white'>"
    objDocument.Writeln "Retrieving Users membership Information. Please wait. <p>"


    Dim rootDSE, domainObject, oFSO, oTS
    Set rootDSE=GetObject("LDAP://RootDSE")
    domainContainer = rootDSE.Get("defaultNamingContext")
    Set oDomain = GetObject("LDAP://" & domainContainer)
    Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
    Set OTS = oFSO.CreateTextFile("C:\users.csv",True)
     

    WorkWithObject(oDomain)
     
    Sub WorkWithObject(oContainer)
    Dim oADObject
    For Each oADObject in oContainer
    Select Case oADObject.Class
    Case "user"
    oTS.Write oADObject.Get("distinguishedName")
    oTS.Write ","
    oTS.Write chr(13) & chr(10)
                           
    Case "organizationalUnit" , "container"
    WorkWithObject(oADObject)
    End select
    Next
    End Sub

    For Each oADObject in oDomain

    objDocument.Writeln "*"

    Next

    objDocument.Writeln "<br>Users membership information retrieved!"
    objDocument.Writeln "</body></html>"
    Wscript.Sleep 4000
    objDocument.Close
    objExplorer.Quit

     

     

     

    jueves, 31 de enero de 2008 12:07
  • Gracias Pablo, ¿pero si solo quiero localizar un usuario?

     

    jueves, 31 de enero de 2008 12:12
  •  

     

    Code Snippet

    Const ADS_SCOPE_SUBTREE = 2

    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand =   CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection

    FindUser = InputBox("Please Enter A UserName", "Find User OU")
    If FindUser = "" Then
    MsgBox("No UserName Was Added")
    WScript.Quit
    Else
    strUser = FindUser
    End If

    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    objCommand.CommandText = _
        "SELECT distinguishedName FROM 'LDAP://dc=xxxxx,dc=yyy'WHERE objectCategory='user'AND sAMAccountName='" & strUser & "'"
    Set objRecordSet = objCommand.Execute

    objRecordSet.MoveFirst
    Do Until objRecordSet.EOF
        strDN = objRecordSet.Fields("distinguishedName").Value
        arrPath = Split(strDN, ",")
        intLength = Len(arrPath(1))
        intNameLength = intLength - 3
        Wscript.Echo strUser & " --> " & Right(arrPath(1), intNameLength)
        objRecordSet.MoveNext
    Loop

     

     

     

     

    jueves, 31 de enero de 2008 13:12
  • Puedes utilizar un query en el Active Directory y luego ver las propiedades del usuario.

    Using Saved Queries http://technet2.microsoft.com/WindowsServer/en/library/075c22c0-6204-441b-9ee9-fa0ccbc0ca1e1033.mspx


    Slds
    Sebastian del Rio

    jueves, 31 de enero de 2008 14:10
    Moderador
  • simplemente es la parte de usuarios del active directory tiene buscar, entras hay por el tipo de cosa o objeto que buscas el nombre y te va a dar una lista de ellos y donde estan ubicados en el dominio.
    viernes, 1 de febrero de 2008 1:20
  •  

    Muchas Gracias, lo probare el lunes.

    Un saludo

    viernes, 1 de febrero de 2008 15:45