Page 1 of 1 1
Topic Options
#117533 - 2004-04-08 04:07 PM Add Computer to Active Directory Group
MrGravis Offline
Lurker

Registered: 2004-04-08
Posts: 3
Hello all!

I am working on a script that will add a computer to a group based on ip address. I got the ip address part working, and can tell what group the computer should be in, but I don't know how to add a computer to a group in AD.

There are many examples on the site here on how to add users to a group, GroupAdd() for example, but that doesn't seem to work for computer objects.

Any ideas?

Top
#117534 - 2004-04-08 04:25 PM Re: Add Computer to Active Directory Group
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Don't have code on a silver platter, but the doubt the GroupAdd() would work since it uses the WinNT provider and computer groups are not supported. You may want to give the LDAP provider a go.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#117535 - 2004-04-08 04:45 PM Re: Add Computer to Active Directory Group
MrGravis Offline
Lurker

Registered: 2004-04-08
Posts: 3
Is there a command or any info that you could direct me to so I can do some more research?

I'm just starting with kixtart.

Top
#117536 - 2004-04-08 04:54 PM Re: Add Computer to Active Directory Group
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The best LDAP resource is MSDN.
_________________________
There are two types of vessels, submarines and targets.

Top
#117537 - 2004-04-08 05:51 PM Re: Add Computer to Active Directory Group
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Check out the AD Cookbook

It's vbscript, but is easily converted

_________________________
Eric

Top
#117538 - 2004-04-08 06:35 PM Re: Add Computer to Active Directory Group
MrGravis Offline
Lurker

Registered: 2004-04-08
Posts: 3
Quote:

Check out the AD Cookbook

It's vbscript, but is easily converted






Funny, I just found that and was coming back here to share the info.

Code:
' This VBScript code adds a member to a group.


' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00466-4
' Book web site: http://rallenhome.com/books/adcookbook/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strGroupDN = "GROUP" ' e.g. cn=SalesGroup,ou=Groups,dc=rallencorp,dc=com
strMemberDN = "OBJECT" ' e.g. cn=jsmith,cn=users,dc=rallencorp,dc=com
' ------ END CONFIGURATION ---------

set objGroup = GetObject("LDAP://" & strGroupDN)
' Add a member
objGroup.Add("LDAP://" & strMemberDN)



Edited by MrGravis (2004-04-08 06:36 PM)

Top
#117539 - 2004-04-09 12:55 AM Re: Add Computer to Active Directory Group
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
See this UDF ComputerInGroup()
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=83581

You can try changing the "$oGrp.IsMember" to "$oGrp.Add". That should be just as effective with local and global groups.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.122 seconds in which 0.088 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org