Help With User Object - Getting Attributes

Help With User Object - Getting Attributes

Post by Aaro » Thu, 14 Nov 2002 12:03:41



Hi, I have been playing around with adsi and ldap stuff for a day or so, I
have it working okay to a degree but I am having problems retrieving
additional attributes for a user object, such as Phone-Mobile-Primary or
similar.

Does anyone have some ASP (VBscript) script that will retrieve these things?
I have found lots of tutorials and examples on how to retrieve the simple
stuff like samAccountName.

as an example I have tried the following

 <%= objUserWinNT.Get( "mobile" ) %>

which results in a 500 error with the message "The Active Directory property
cannot be found in the cache"

So I guess that I am trying to get a property with the above and not an
attribute.

So my question is basicly, how do I retrieve an attribute such as the phone
number, or the email address of a user etc?

Thanks
Aaron

Below is a snippet of the script that I use with the above

 Const strDomain = "Waikato"
 Const strLdapOU = "OU=InnovatorsOnlineNetwork, OU=wms-users, OU=wms,
DC=waikato, DC=ac, DC=nz"
 Const gSubscribers = "ION-Subscribers"
 Const gAuthors = "ION-Authors"
 Const gEditors = "ION-Editors"
 Const gModeratros = "ION-Moderators"

 Dim objUserWinNT, objUserLdap, objGroup, strUser

 Set objLdapGroup = GetObject( "LDAP://" & strLdapOU )

Function MakeUserObject( strUsername )
 Dim GroupObj, UsrObj
 Set objUserWinNT = GetObject("WinNT://" & strDomain & "/" & strUsername &
",user" )

 Set GroupObj = GetObject( "LDAP://" & strLdapOU )

 For each UserObj in GroupObj
  If UserObj.Class = "user" Then
   If UserObj.sAMAccountName = strUsername Then
    Set objUserLdap = UserObj
   End If
  End If
 Next

 objUserWinNT.GetInfo()
 objUserLdap.GetInfo()

End Function

 MakeUserObject( "aaronc" )

%>
<pre>
 Username:   <%= objUserWinNT.Name %>
 FullName:   <%= objUserWinNT.FullName %>
 Description:   <%= objUserWinNT.Description %>
 Password Never Expires:  <%= ( ( objUserWinNT.get( "UserFlags" ) And
&H10000 ) = 1 ) %>
 Account Disabled:  <%= objUserWinNT.AccountDisabled %>
 User is in <%= gSubscribers %>: <%= DispUserInGroup( gSubscribers ) %>

 
 
 

Help With User Object - Getting Attributes

Post by Marc Scheune » Thu, 14 Nov 2002 22:09:54




Quote:>Hi, I have been playing around with adsi and ldap stuff for a day or so, I
>have it working okay to a degree but I am having problems retrieving
>additional attributes for a user object, such as Phone-Mobile-Primary or
>similar.

First of all, you'll need to use the LDAP display name for the
attributes, if you want to retrieve them. They usually begins with a
lowercase letter, and the individual words are capitalized after that,
e.g. otherTelephoneMobile, etc.

Quote:>which results in a 500 error with the message "The Active Directory property
>cannot be found in the cache"

Two possible reasons: you haven't read the values into the cache by
calling a .GetInfo on the object, and more likely, there's just no
value associated with that attribute yet (nothing has been set for
that attribute yet).

Marc

 
 
 

Help With User Object - Getting Attributes

Post by Aaro » Fri, 15 Nov 2002 07:08:51


Thanks Mark!
    I thought about your second idea before I posted, so yes the attribute
does have a value assigned to it. However I still uncertain about your first
Idea. In the SDK the Attribute details for Phone-Mobile-Primary are:
      CN: Phone-Mobile-Primary
      Ldap-Display-Name: mobile

    So; with the given details about the attribute Phone-Mobile-Primary you
have said that I should try the name "phoneMobilePrimary" however you have
indicated that I should use the display name which is "mobile" so I have
tried both and....

    After a lot of playing around I have found that I had in fact not set
the Attribute value. so For anyone else who is having issues with retrieving
attributes
here tis.

In the Platform sdk, or what ever documentation you are using, you need to
find the "Ldap-Display-Name" of the attribute you want to retrieve.

Make sure it is set with ldap

objUserLDAP.Put "mobile", "+64 21 355 553"
objUserLDAP.setInfo

objUserLDAP.Get( "mobile" )

and thats it.

Once again Thankyou for your help Mark!
Aaron




> >Hi, I have been playing around with adsi and ldap stuff for a day or so,
I
> >have it working okay to a degree but I am having problems retrieving
> >additional attributes for a user object, such as Phone-Mobile-Primary or
> >similar.

> First of all, you'll need to use the LDAP display name for the
> attributes, if you want to retrieve them. They usually begins with a
> lowercase letter, and the individual words are capitalized after that,
> e.g. otherTelephoneMobile, etc.

> >which results in a 500 error with the message "The Active Directory
property
> >cannot be found in the cache"

> Two possible reasons: you haven't read the values into the cache by
> calling a .GetInfo on the object, and more likely, there's just no
> value associated with that attribute yet (nothing has been set for
> that attribute yet).

> Marc

 
 
 

1. Change user object attribute on all users in AD domain

i'm on the lookout for a script that will change the info
attribute on every user in the domain.  I'm new to ADSI
and from my reading thus far seem to have broken the task
into the following three operations. 1) enumerate all
user objects in the domain, 2) identify some way to find
the full LDAP context of the object and 3) finally update
the attribute and .SetInfo.  Does anyone have any
suggestions or examples of how this can be done?

I was working with ADO initially but discovered that it
does not have any update facilities for AD.  Using the
following script i am able to enumerate all users, but
that is about as far as I have gotten.  Thanks in advance.

Dan

Dim oDomain
        Dim strDomainName
        Dim User
        strDomainName = "shastalink"
        Set oDomain = GetObject("WinNT://microsoft")
        oDomain.Filter = Array("User")
        For Each User in oDomain
                 Wscript.Echo User.Name
                 'User.GetInfo
                 'User.Info = Null
                 'User.SetInfo
        Next
Set oDomain = Nothing

2. DOS SPEDD

3. getting attributes of computer object

4. OS/2 Lan Requestor.

5. Setting "memberOf" attribute of the User Object with LDAP

6. NJ A/C Split and Cellular

7. Custom Object Class and User attribute

8. H/D re-booting

9. modify user objects Country\Region attribute?

10. Adding properties (attributes) to existing objects... help!

11. Users keep getting Word files with Read-Only attribute

12. Getting AD user's attributes

13. Help with getting all users out of groups, more than 1000 users