Announcement

Collapse
No announcement yet.

add user to group with vbscript error

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

  • add user to group with vbscript error

    Hello,

    I have a problem with my script to add a user to a group.

    the script is:

    'Add User To group
    '---------------------

    Function AddToGRP(ByVal stUser, ByVal stOU, ByVal stGroup)
    Dim strDNSDomain,strDNSDomain1,strDNSDomain2
    Dim objRootLDAP, objGroup, objUser,obj
    Const ADS_PROPERTY_APPEND = 3

    ' Check these objects referenced by strOU, strGroup exist in strOU
    'strOU = "OU=Newport,"
    'strUser = "CN=Len Murray,"
    'strGroup = "CN=Coal Porters,"

    ' Bind to Active Directory and get LDAP name
    Set objRootLDAP = GetObject("LDAP://RootDSE")
    strDNSDomain = objRootLDAP.Get("DefaultNamingContext")

    ' Add (str)User to (str)Group

    Set objUser = GetObject("LDAP://" & stUser & stOU & strDNSDomain)
    Set objGroup = GetObject("LDAP://" & stGroup & stOU & strDNSDomain)

    AddToGRP="1"

    objGroup.Add(objUser.ADsPath)
    objGroup.SetInfo
    WScript.Echo "Check " & strOU & " for " & strGroup & " = " & strUser
    End Function

    and the error i get is:

    a referral was returned from the server
    code: 8007202B

    Can someone help me?

    Thankes

  • #2
    Re: add user to group with vbscript error

    "Error messages beginning 8007xxxx mean there is an external problem with Windows rather than syntax in the VBScript itself.
    My suggestion is that there is a typo in the domain name reference in your script."
    http://www.computerperformance.co.uk...e_8007202B.htm


    The script you sent is not the script how you use it (I hope).
    The code you sent is only a script Function, which should be a part of a script. The nesseary variable string values are not available to Set the object User and the object Group.


    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X