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
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
Comment