PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.win.server.scripting > Can't get simple LDAP script to work
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Can't get simple LDAP script to work

Réponse
 
LinkBack Outils de la discussion
Vieux 04/10/2007, 12h23   #1
Bobby
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Can't get simple LDAP script to work

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

  Réponse avec citation
Vieux 04/10/2007, 14h20   #2
Bobby
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can't get simple LDAP script to work

Sorry, I meant to add, that the error I get is:

Automation Error
A referral was returned from the Server

  Réponse avec citation
Vieux 04/10/2007, 14h32   #3
Marcelo Moraes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can't get simple LDAP script to work


I'm using this LDAP query inside AD


(&(objectCategory=person)(objectClass=user)(member Of=CN=groupname,OU=Data,OU=Groups,DC=test,DC=msft, DC=net))


The Object Class is memberof

On Thu, 04 Oct 2007 12:20:02 -0000, Bobby <bobby2@blueyonder.co.uk>
wrote:

>Sorry, I meant to add, that the error I get is:
>
>Automation Error
>A referral was returned from the Server

  Réponse avec citation
Vieux 04/10/2007, 15h12   #4
Bobby
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can't get simple LDAP script to work

Ok, panic over. I found a thread called "scripting newbie", and this
answers my question. Thanks Richard,

Colin


  Réponse avec citation
Vieux 05/10/2007, 10h35   #5
Bobby
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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


  Réponse avec citation
Vieux 06/10/2007, 20h21   #6
Al Dunbar
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Can't get simple LDAP script to work


"Bobby" <bobby2@blueyonder.co.uk> wrote in message
news:1191573358.712494.70590@22g2000hsm.googlegrou ps.com...
> 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


A few points that might cause this to work less than perfectly in some
situations:

- membership through nested groups will not be discovered.
- if user SmithXX is a member but user SmithX is not, SmithX will be deemed
a member because "SmithX" will be found within "SmithXX"
- any user account that is coincidentally found in the adspath will appear
to be a member, for example, users Acco, and MyCom.

/Al


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h19.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12963 seconds with 14 queries