Q. How can I add a user to a group by using Microsoft Active Directory Service Interfaces (ADSI) in a script?

A. You can use VBScript code that's similar to the following snippet, which adds a user to a group by using the user's distinguished name (DN):

Set grp = GetObject("LDAP://cn=testgrp,ou=testing,dc=savilltech,dc=com")
Set oUser = GetObject("LDAP://cn=user1,ou=testing,dc=savilltech,dc=com")
grp.Add(oUser.AdsPath)
grp.SetInfo
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish