Re: Can't get simple LDAP script to work
On 4 Oct, 11:23, Bobby <bob...@blueyonder.co.uk> wrote:
> Hi
> I'm new to LDAP. I'm trying to use the script below (copied from
> Technet) to list all of the members in an AD group. I'm struggling
> with this, and wondered if anybody could me out. The script is:
>
> On Error Resume Next
>
> Set objGroup = GetObject _
> ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
> objGroup.GetInfo
>
> arrMemberOf = objGroup.GetEx("member")
>
> WScript.Echo "Members:"
> For Each strMember in arrMemberOf
> WScript.echo strMember
> Next
>
> My group is called "Accounts", which is under a folder called
> "Company" in Active Directory and users. The domain name is mycompany-
> uk.com. The best I can come up with is:
>
> Set objGroup = GetObject _
> ("LDAP://cn=Accounts,ou=Company,dc=mycompany-uk,dc=com")
>
> Unfortunately this doesn't work. What am I doing wrong?
>
> Sorry if this is a daft question. Thanks for any ,
>
> Colin
Just in case anybody is interested, here's some code I wrote in Access
to determine if a user is a member of the Accounts group. Ok, I know
it's not the greatest code in the World, but it's simple and it works:
Function fGetAccountsUsers() As Boolean
' returns all of the members of the Accounts group
Set objGroup = GetObject _
("LDAP://cn=Accounts,ou=MyCompany,dc=MyDomain,dc=local")
objGroup.GetInfo
arrmemberof = objGroup.GetEx("member")
For Each strmember In arrmemberof
If InStr(strmember, "User Name") Then
fGetAccountsUsers = True
Exit Function
End If
Next
fGetAccountsUsers = False
End Function
|