Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Move computers depending on group membership

Status
Not open for further replies.

jamesjames1

Technical User
Jun 18, 2004
81
GB
Hi,

I am trying to script a computer account move in AD which depends on the last logged on users group membership. I cant do this from a login script so need to do it from a domain controller.

I have got the code to get the users group membership and this populates an array. I am having difficulty searching through the array for the group name. Here is the code to get the group which the user is a member of:

strUserDN = "<UserDN>" cn=jsmith,cn=Users,dc=rallencorp,dc=com
' ------ END CONFIGURATION ---------
set objUser = GetObject("LDAP://" & strUserDN)
Wscript.Echo "Group membership for " & objUser.Get("cn") & ":"
strSpaces = ""
set dicSeenGroup = CreateObject("Scripting.Dictionary")
DisplayGroups "LDAP://" & strUserDN, strSpaces, dicSeenGroup

Function DisplayGroups ( strObjectADsPath, strSpaces, dicSeenGroup)

set objObject = GetObject(strObjectADsPath)
WScript.Echo strSpaces & objObject.Name
on error resume next ' Doing this to avoid an error when memberOf is empty
if IsArray( objObject.Get("memberOf") ) then
colGroups = objObject.Get("memberOf")
else
colGroups = Array( objObject.Get("memberOf") )
end if

for each strGroupDN In colGroups
if Not dicSeenGroup.Exists(strGroupDN) then
dicSeenGroup.Add strGroupDN, 1
DisplayGroups "LDAP://" & strGroupDN, strSpaces & " ", dicSeenGroup
end if
next

End Function


I am reading the DN's from an excel spreadsheet so have added a loop which takes the name from the spreadsheet, populates the strUserDN variable then loops. I plan to write a select statement with the various group to call various sub routines to move the computer objects.

Any help would be good
 
How do you determine which computer a user logged into?

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Hi,

Got the data out using LANDesk. The client is deployed via a login script and it uses SQL. Its a front end web app with export to CSV and its pretty good. Did some data manipulation in Access..

Hope this helps

james
 
I don't see an array in your code. I do see a Globally declared Dictionary Object though, which could be used for your lookup. Maybe you can rephrase your issue?


PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top