WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Hierarchically Adding Users to Groups


AddExtender("WWWNT34i.DLL")
addExtender("WWADS34I.DLL")
sAdsiPath = 'LDAP://domain.com' 
IntControl (40, 1, 0, 0, 0)
handle=fileopen("C:\temp\Test-group-import.txt", "write")
dc=wntGetDc( "", "", 0)
globalgroups= wntAcctList( dc, 3, 0)
groupscnt=itemcount(globalgroups, @TAB)
for x=1 to groupscnt
	thisgroup=itemextract(x, globalgroups, @TAB)
	rslt1 = StrCnt(thisgroup, "_", 1, -1, 0)
	rslt2 = StrCnt(thisgroup, "Domabt", 1, -1, 0)
	if rslt1 == 2 & rslt2 == 1
		Grouppath= ""
		Grouppath= dsFindPath(sAdsiPath, "sAMAccountName=%thisgroup%")
		GroupParentPath= ""
		GroupParentPath= dsGetPrntPath(Grouppath)
		GroupParentChildrenPath = ""
		GroupParentChildrenPath = dsGetChldPath(GroupParentPath, "organizationalUnit")
		if strindexnc(GroupParentChildrenPath, "Users", 0, @FWDSCAN)
			searchFilter = "(&(objectCategory=person)(objectClass=user))"
			LDAPGroupResults = ""
			LDAPGroupResults = dsFindPath(GroupParentPath , searchFilter) 
			If LDAPGroupResults != ""
				LDAPGroupResultCount=itemcount(LDAPGroupResults, @TAB)
				for y=1 to LDAPGroupResultCount
					ThisUserPath=itemextract(y, LDAPGroupResults, @TAB)
					TestMember=dsIsMemberGrp(Grouppath,ThisUserPath)
					If TestMember == 1 
						;nothing to do!
					Else
						dsAddToGrp(Grouppath, ThisUserPath)
						filewrite(handle, strcat(thisgroup, " - ",ThisUserPath))
					EndIf
				next
			endif
		endif
	endif
next
fileclose(handle)
exit


Article ID:   W16332
File Created: 2005:02:18:12:19:48
Last Updated: 2005:02:18:12:19:48