Novice question

Novice question

Post by Alan » Sun, 03 Nov 2002 01:23:41



OK, I've given in...

This must seem mundane to you guys, or maybe I'm just having a bad hair day,
but all I want to do is...

Return an ordered list (on Name) with accompanying telephone number of all
of the users in a particular group with ADSI.

I have scoured the internet, tried various combinations of methods to no
avail, I must be missing something simple.
Can anyone enlighten me.
Ta
Alan

 
 
 

Novice question

Post by weiw » Sun, 03 Nov 2002 13:45:33


Hi
well, do you have some vbscript already, so we can take look at it, in
order to help you out.
I have post some user's telephone question return from AD back in Oct,
you can go back the posting, it should be there.
any question, let me know
Wei

> OK, I've given in...

> This must seem mundane to you guys, or maybe I'm just having a bad hair day,
> but all I want to do is...

> Return an ordered list (on Name) with accompanying telephone number of all
> of the users in a particular group with ADSI.

> I have scoured the internet, tried various combinations of methods to no
> avail, I must be missing something simple.
> Can anyone enlighten me.
> Ta
> Alan


 
 
 

Novice question

Post by Richard Muelle » Sun, 03 Nov 2002 14:06:49



>OK, I've given in...

>This must seem mundane to you guys, or maybe I'm just

having a bad hair day,
Quote:>but all I want to do is...

>Return an ordered list (on Name) with accompanying

telephone number of all
Quote:>of the users in a particular group with ADSI.

>I have scoured the internet, tried various combinations
of methods to no
>avail, I must be missing something simple.
>Can anyone enlighten me.
>Ta
>Alan

Hi,

I would not call this task easy. If I understand the
question, it's a bit of a challenge. I assume you want to
sort the list by sAMAccountName, which is the NT name,
also called the pre-W2k logon name.

I see two approaches. The first would be:

1. Bind to the group object with the LDAP provider (WinNT
does not expose TelephoneNumber).
2. Enumerate the group Members collection.
3. For each group member, populate an array with the
sAMAccountName and TelephoneNumber properties. The array
would be dynamic, and you would ReDim it for each user.
4. Sort the array by sAMAccountName, using a bubble sort
routine.
5. Loop thru the array to create your list.

The method I chose:
1. Using ADO, search AD for all user objects where one
item in the MemberOf collection attribute is equal to the
AdsPath of the group. Request the attributes
sAMAccountName and TelephoneNumber, and order the
recordset by sAMAccountName.
2. Loop thru the recordset and create the list.

I hard coded the group AdsPath below. More code would be
needed if you started with just the sAMAccountName of the
group (you would have to use the NameTranslate object to
convert to the LDAP AdsPath). Also, I assumed that all
objects found are user objects.

sGroup = "cn=MyGroup,cn=Users,dc=MyDomain,dc=com"
Set oRoot = GetObject("LDAP://RootDSE")
sDNSDomain = oRoot.Get("DefaultNamingContext")
Set oCommand = CreateObject("ADODB.Command")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Open = "Active Directory Provider"
oCommand.ActiveConnection = oConnection
sQuery = _
  "SELECT sAMAccountName, TelephoneNumber FROM 'LDAP://" _
  & sDNSDomain & "' WHERE MemberOf = '" _
  & sGroup & "' ORDER by sAMAccountName"
oCommand.CommandText = sQuery
oCommand.Properties("Page Size") = 100
Set oResults = oCommand.Execute
If oResults.EOF Then
  MsgBox "No users found"
  Wscript.Quit
End If

Do Until oResults.EOF
  sName = oResults.Fields("sAMAccountName")
  sPhone = oResults.Fields("TelephoneNumber")
  sDisplay = sName & ", " & sPhone & vbCrLf
  oResults.MoveNext
Loop
MsgBox sDisplay

I don't know the format you want for the list.

Richard

 
 
 

Novice question

Post by Alan » Tue, 05 Nov 2002 19:25:11


Richard,

Thankyou for your help.
That was exactly what I was after.
You're a star!

Alan



> >OK, I've given in...

> >This must seem mundane to you guys, or maybe I'm just
> having a bad hair day,
> >but all I want to do is...

> >Return an ordered list (on Name) with accompanying
> telephone number of all
> >of the users in a particular group with ADSI.

> >I have scoured the internet, tried various combinations
> of methods to no
> >avail, I must be missing something simple.
> >Can anyone enlighten me.
> >Ta
> >Alan

> Hi,

> I would not call this task easy. If I understand the
> question, it's a bit of a challenge. I assume you want to
> sort the list by sAMAccountName, which is the NT name,
> also called the pre-W2k logon name.

> I see two approaches. The first would be:

> 1. Bind to the group object with the LDAP provider (WinNT
> does not expose TelephoneNumber).
> 2. Enumerate the group Members collection.
> 3. For each group member, populate an array with the
> sAMAccountName and TelephoneNumber properties. The array
> would be dynamic, and you would ReDim it for each user.
> 4. Sort the array by sAMAccountName, using a bubble sort
> routine.
> 5. Loop thru the array to create your list.

> The method I chose:
> 1. Using ADO, search AD for all user objects where one
> item in the MemberOf collection attribute is equal to the
> AdsPath of the group. Request the attributes
> sAMAccountName and TelephoneNumber, and order the
> recordset by sAMAccountName.
> 2. Loop thru the recordset and create the list.

> I hard coded the group AdsPath below. More code would be
> needed if you started with just the sAMAccountName of the
> group (you would have to use the NameTranslate object to
> convert to the LDAP AdsPath). Also, I assumed that all
> objects found are user objects.

> sGroup = "cn=MyGroup,cn=Users,dc=MyDomain,dc=com"
> Set oRoot = GetObject("LDAP://RootDSE")
> sDNSDomain = oRoot.Get("DefaultNamingContext")
> Set oCommand = CreateObject("ADODB.Command")
> Set oConnection = CreateObject("ADODB.Connection")
> oConnection.Provider = "ADsDSOObject"
> oConnection.Open = "Active Directory Provider"
> oCommand.ActiveConnection = oConnection
> sQuery = _
>   "SELECT sAMAccountName, TelephoneNumber FROM 'LDAP://" _
>   & sDNSDomain & "' WHERE MemberOf = '" _
>   & sGroup & "' ORDER by sAMAccountName"
> oCommand.CommandText = sQuery
> oCommand.Properties("Page Size") = 100
> Set oResults = oCommand.Execute
> If oResults.EOF Then
>   MsgBox "No users found"
>   Wscript.Quit
> End If

> Do Until oResults.EOF
>   sName = oResults.Fields("sAMAccountName")
>   sPhone = oResults.Fields("TelephoneNumber")
>   sDisplay = sName & ", " & sPhone & vbCrLf
>   oResults.MoveNext
> Loop
> MsgBox sDisplay

> I don't know the format you want for the list.

> Richard

 
 
 

1. novice questions SBS/Exchange and Outlook98

Hi,

I'm fairly new to SBS (well actually I'm new to NT and Exchange. I
know it seems odd that someone could live without using MS products
for years :-)) )
I've managed to switch my entire LAN (server and clients) to SBS and
NT WS. So now I have a few questions and I hope that someone can point
me in the right direction:

We're using SBS/Exchange with Outlook98 clients. As a newsreader I'm
using a 3rd party product but I'd like to use Exchange as my News
Server and Outlook Express as my clients in order to read news
OFFLINE.
Is there a description somewhere of how to setup Exchange so it
retrieves News from one or more of the news servers in the internet,
(like automatically retrieve all new headers at night) and then have
the individual clients to retrieve only those messages they're
interested in? Both, headers and message bodies should be stored on
the Exchange server though.

Another question (which might sound dumm but as I said: I'm new in the
MS world):
How can I setup additional GLOBAL addressbooks in Exchange and
Outlook?
What I want to achieve is to store all external adresses like business
partners eMail partners etc. in a new addressbook which should be
accessible by all users in our LAN (all are using SBS/Exchange and
Outlook 98 clients)

Please don't respond RTMF. I have searched all the online docs but
couldn't find any reference to how to setup new global address books
:-((

Thanks
Richard

2. 3d border on textbox

3. Novice question on SMS

4. Fonts crash/disappearing

5. a novice question - samba

6. NA Authorized Dealer List 11-24-95

7. A novice questions.

8. FP2000 problem with FP98 extension

9. Novice SAMBA user has question on sharing...

10. novice samba question

11. novice server admin PLS ADVISE.

12. novice needs advice

13. Connecting with RAS (novice)