Re: Access Denied
- From: "Joe Kaplan" <joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 13 Mar 2008 16:26:56 -0500
Are you sure the current logged on user is an ADAM admin and has permissions
to do such operations?
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"John" <John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CA56E663-51AF-45B3-B598-36C3AE3F9466@xxxxxxxxxxxxxxxx
Can anyone tell me why I get an access denied error using this code? I am
wanting to be able t dynamically add and remove users from a group using a
login script. The code below is supposed to remove a user, but I get an
access denied message.
The object and group get successfully set with the code, but
objGroup.Remove
objUser.AdsPath fails.
Dim objADAM ' Binding object.
Dim objGroup ' Group object.
Dim objUser ' User object.
Dim strGroup ' Group.
Dim strPath ' Binding path.
Dim strOU ' Organizational unit.
Dim strUser ' User.
' Construct the binding string.
strPath = "Some path here"
WScript.Echo "Bind to: " & strPath
' Specify User.
strUser = "CN..."
' Specify Group.
strGroup = "CN..."
WScript.Echo "Remove: " & strUser
WScript.Echo " from"
WScript.Echo " " & strGroup
' Bind to root.
Set objADAM = GetObject(strPath)
' Output error if bind fails.
If Err.Number <> vbEmpty Then
WScript.Echo "Error: Bind failed."
WScript.Quit
End If
' Remove User from Group.
Set objGroup = objADAM.GetObject("group", strGroup)
Set objUser = objADAM.GetObject("user", strUser)
objGroup.Remove objUser.AdsPath
' Output success or error.
If Err.Number <> vbEmpty Then
WScript.Echo "Error: Remove failed."
WScript.Echo Err.Description
Else
WScript.Echo "Success: User removed from group."
End If
.
- Follow-Ups:
- Re: Access Denied
- From: John
- Re: Access Denied
- References:
- Access Denied
- From: John
- Access Denied
- Prev by Date: Re: Unknown LDAP query
- Next by Date: Re: salutation
- Previous by thread: Access Denied
- Next by thread: Re: Access Denied
- Index(es):
Relevant Pages
|