add user to group with vbscript error

Home Forums Scripting General Scripting add user to group with vbscript error

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    adk
    Member
    #127988

    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

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.