Hi,
i try to run this little script on Win 2003 Server and win
2000 server . At the line 17 :
strGivenName = objUser.Get("givenName")
I receive a msg that say the object do not support .Get
("givenName"). All others .Get("") doesnt work. Only
objUser.Name work.
Why ?
Tanx
Eric

*********************************************************
strComputer = "."
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")

Const ForAppending = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\scripts\service_status.txt", ForAppending, True)

For Each objGroup In colGroups
objTextFile.WriteLine("GROUP :" objGroup.Name)
For Each objUser in objGroup.Members
objUser.GetInfo

strGivenName = objUser.Get("givenName")
strInitials = objUser.Get("initials")
strSn = objUser.Get("sn")
strDisplayName = objUser.Get("displayName")
strPhysicalDeliveryOfficeName = _
objUser.Get("physicalDeliveryOfficeName")
strTelephoneNumber = objUser.Get
("telephoneNumber")
strMail = objUser.Get("mail")
strWwwHomePage = objUser.Get
("wWWHomePage")

strDescription = objUser.GetEx
("description")
strOtherTelephone = objUser.GetEx
("otherTelephone")
strUrl = objUser.GetEx("url")

objTextFile.WriteLine(strGivenName)
objTextFile.WriteLine(strInitials)
objTextFile.WriteLine(strGivenName)
objTextFile.WriteLine(strInitials)

objTextFile.WriteLine("sn: " & strSn)
objTextFile.WriteLine("displayName: " &
strDisplayName)
objTextFile.WriteLine
("physicalDeliveryOfficeName: " &
strPhysicalDeliveryOfficeName)
objTextFile.WriteLine("telephoneNumber: "
& strTelephoneNumber)
objTextFile.WriteLine("mail: " & strMail)
objTextFile.WriteLine("mail: " & strMail)
Next
Next

objTextFile.Close

Re: Object proprety not supported by Richard

Richard
Wed Sep 17 11:06:53 CDT 2003

Eric wrote:

> Hi,
> i try to run this little script on Win 2003 Server and win
> 2000 server . At the line 17 :
> strGivenName = objUser.Get("givenName")
> I receive a msg that say the object do not support .Get
> ("givenName"). All others .Get("") doesnt work. Only
> objUser.Name work.
> Why ?
> Tanx
> Eric
>
> *********************************************************
> strComputer = "."
> Set colGroups = GetObject("WinNT://" & strComputer & "")
> colGroups.Filter = Array("group")
>
> Const ForAppending = 2
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile _
> ("c:\scripts\service_status.txt", ForAppending, True)
>
> For Each objGroup In colGroups
> objTextFile.WriteLine("GROUP :" objGroup.Name)
> For Each objUser in objGroup.Members
> objUser.GetInfo
>
> strGivenName = objUser.Get("givenName")
> strInitials = objUser.Get("initials")
> strSn = objUser.Get("sn")
> strDisplayName = objUser.Get("displayName")
> strPhysicalDeliveryOfficeName = _
> objUser.Get("physicalDeliveryOfficeName")
> strTelephoneNumber = objUser.Get
> ("telephoneNumber")
> strMail = objUser.Get("mail")
> strWwwHomePage = objUser.Get
> ("wWWHomePage")
>
> strDescription = objUser.GetEx
> ("description")
> strOtherTelephone = objUser.GetEx
> ("otherTelephone")
> strUrl = objUser.GetEx("url")
>
> objTextFile.WriteLine(strGivenName)
> objTextFile.WriteLine(strInitials)
> objTextFile.WriteLine(strGivenName)
> objTextFile.WriteLine(strInitials)
>
> objTextFile.WriteLine("sn: " & strSn)
> objTextFile.WriteLine("displayName: " &
> strDisplayName)
> objTextFile.WriteLine
> ("physicalDeliveryOfficeName: " &
> strPhysicalDeliveryOfficeName)
> objTextFile.WriteLine("telephoneNumber: "
> & strTelephoneNumber)
> objTextFile.WriteLine("mail: " & strMail)
> objTextFile.WriteLine("mail: " & strMail)
> Next
> Next
>
> objTextFile.Close

Hi,

You need to use the LDAP provider. The WinNT provider does not expose most
of the attributes you are using, such as givenName.

However, you are binding to a local machine and enumerating the local
machine groups and members, which can only be done with WinNT. The code you
posted is appropriate for Active Directory users, but not local users and
groups. The attributes do not exist for local users. Some of the attributes
that do exist are:

fullName, description, name, profile, loginScript, homeDirectory, and
homeDirDrive.

I have a feeling you mean to enumerate Active Directory users. If your
domain is MyDomain.com, and all users are in the "cn=Users" container, you
could enumerate all groups, and for each group enumerate all direct members,
with code similar to:

Set objContainer = GetObject("LDAP://cn=Users,dc=MyDomain,dc=com")
objContainer.Filter = Array("group")
For Each objGroup In objContainer
Wscript.Echo "Group: " & objGroup.sAMAccountName
For Each objUser In objGroup.Members
Wscript.Echo "-- member: " & objUser.sAMAccountName
Next
Next

If the users are in an OU, you must bind to the OU. If the users can be in
several containers/OU's, you should use ADO to query AD.

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--