ADSI User object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vorpal
    New Member
    • May 2007
    • 2

    ADSI User object

    I have a vbScript function that works quite well, but fails when I attempt to run it in an ASP pages.

    Here is the function:
    [code=asp]Function GetGroups(Disti nguishedName)
    'Returns an array of groups or a 1-element array detailing the error.

    Const E_ADS_PROPERTY_ NOT_FOUND = &h8000500D

    Dim oUser,asGroups, sGp
    Dim oConn,oCmd,oRS

    'This object is not set correctly when on an ASP page
    Set oUser = GetObject(Disti nguishedName)

    On Error Resume Next
    asGroups = oUser.GetEx("me mberOf") 'An array of groups
    If Err.Number <> 0 Then
    if Err.Number = E_ADS_PROPERTY_ NOT_FOUND Then
    asGroups=Array( "Err.Number","t he member attribute is not set")
    else
    asGroups=Array( Err.Number, Err.Description )
    end if
    End If
    GetGroups=asGro ups
    End Function [/code]

    I've never had any problem using this from vbScript, as long as the logged-on user is a member of the domain.

    I suspect that the problem arises because the asp page is running in a security context that does not allow the ojbect to be created.

    How do I fix this?

    Alternatives?

    --Maugris
    Last edited by jhardman; May 25 '07, 02:41 PM. Reason: put code in code tags
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Maugris,

    ASP is not object oriented so I don't think it will understand what you want. Maybe:
    Code:
    Set oUser = server.createObject(GetObject(DistinguishedName))
    Have you tried this in asp.net?

    Jared

    Comment

    • Vorpal
      New Member
      • May 2007
      • 2

      #3
      Originally posted by jhardman
      Code:
      Set oUser = server.createObject(GetObject(DistinguishedName))
      Have you tried this in asp.net?
      Jared
      Well, it was worth a shot.
      I get a type mismatch, since createobject expects a string.

      So far, I've never used asp.net.
      I set up a test server today so I could begin learning it.
      Not exactly a trivial learning curve.

      For a workaround this time, I'm going to attempt to:
      1. from the asp page run a shell script that puts the requested information in a text file.
      2. Open the text file and iterate it looking for the groups I want.

      It doesn't get much uglier. :)

      If you're interested, I'll let you know if it works.

      --Maugris

      Comment

      Working...