Announcement

Collapse
No announcement yet.

getting all OUs of a user

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting all OUs of a user

    hello all,

    i am trying to get the OU of a user using the following:

    Set oAdsSysObj = CreateObject("ADSystemInfo")
    Set objUser = GetObject("LDAP://" & oAdsSysObj.UserName)
    Set objContainer = GetObject(objUser.Parent)
    wscript.echo objContainer.Get("name")

    and it works just fine. Now what i want to do, is to get a list of all OUs of that specific user.
    how do i do that?

    Thanks everyone.
    Poly.

  • #2
    Re: getting all OUs of a user

    Originally posted by poly
    hello all,

    i am trying to get the OU of a user using the following:

    Set oAdsSysObj = CreateObject("ADSystemInfo")
    Set objUser = GetObject("LDAP://" & oAdsSysObj.UserName)
    Set objContainer = GetObject(objUser.Parent)
    wscript.echo objContainer.Get("name")

    and it works just fine. Now what i want to do, is to get a list of all OUs of that specific user.
    how do i do that?

    Thanks everyone.
    Poly.
    A user will only belong to 1 OU.

    Do you mean groups??

    Comment


    • #3
      Re: getting all OUs of a user

      Originally posted by wullieb1
      A user will only belong to 1 OU.

      Do you mean groups??

      I'm trying to get all the Parents of that user's ou (maybe recursively?)
      Last edited by poly; 19th June 2006, 11:58.

      Comment


      • #4
        Re: getting all OUs of a user

        I'd recommend you a quite new article in the MS Technet, found it very helpful because it lists you all nested groups where the user belongs to ...

        http://www.microsoft.com/technet/tec...y/default.aspx

        Ahh, you've just edited your post ... it might by handy though

        Comment


        • #5
          Re: getting all OUs of a user

          the link you gave me is not so helpfull, since it gives me the groups the user belongs to.
          what I'm looking for is the get the whole tree of the Parent ou's in which the user belongs to.

          for example:

          OU1
          -- OU2
          ----OU3
          ------User

          so the parent of the "User" is "OU3" and i want to get the list of all OUs ("OU1", "OU2", "OU3").

          Comment


          • #6
            Re: getting all OUs of a user

            Maybe try something like this:

            http://www.microsoft.com/technet/scr.../uslsvb18.mspx

            to search for the user first and then it may return the the Object path (such as: GC://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com) which can then be parsed into:

            cn=MyerKen
            ou=Management
            dc=na.fabrikam.com

            Hope this helps
            Server 2000 MCP
            Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

            ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

            Comment

            Working...
            X