Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ADSI AD Active Directory Group Exist
#DefineFunction udfADGroupExists(sGroupName) AddExtender("WWADS44I.DLL") bGroupExists = @FALSE ;Get LDAP defaultNamingContext sServerDn = dsGetProperty("LDAP://rootDSE", "serverName") sServerName = ItemExtract(1, sServerDn, ",") sServerName = ItemExtract(2, sServerName, "=") sServerDn = dsGetProperty("LDAP://rootDSE", "defaultNamingContext") sServerPath = "LDAP://%sServerName%/%sServerDN%" sAdsiPath = dsFindPath (sServerPath, "(& (objectClass=Group) (SAMAccountName=":sGroupName:"))") If sAdsiPath != "" Then bGroupExists = @TRUE Return bGroupExists #EndFunction sGroupName = 'Administrators' ret = udfADGroupExists(sGroupName) If ret Pause('udfADGroupExists', sGroupName : ' group exists.') Else Pause('udfADGroupExists', sGroupName : ' group does not exist.') EndIf Exit
#DefineFunction udfADGroupExists2(sAdsiGroupPath) AddExtender("WWADS44I.DLL") bGroupExists = @FALSE ret = dsIsObject(sAdsiGroupPath) If ret Then bGroupExists = @TRUE Return bGroupExists #EndFunction sAdsiGroupPath = 'LDAP://Server/CN=Administrator,CN=Builtin,DC=domain,DC=local' ;Modify to it your needs ret = udfADGroupExists2(sAdsiGroupPath) If ret Pause('udfADGroupExists2', sAdsiGroupPath : ' group exists.') Else Pause('udfADGroupExists2', sAdsiGroupPath : ' group does not exist.') EndIf Exit
Article ID: W17548
Filename: Group Exist.txt
File Created: 2010:04:29:13:29:54
Last Updated: 2010:04:29:13:29:54