Hi,
I'll read the other thread when I get a chance, but the problem with
userPrincipalName is most likely that it does not always have a value saved
in AD. AD constructs a default value for you, from the sAMAccountName and
the domain of the user.
As with any attribute that can have a missing value, the trick when using
ADO is to account for the Null or missing value. If you use code similar to:
Wscript.Echo adoRecordset.Fields("userPrincipalName").value
You can get a type mismatch error if the attribute value is missing. One fix
is to use:
Wscript.Echo adoRecordset.Fields("userPrincipalName").value & ""
This way, the value will be an Empty string instead of Null or Missing, but
other values are not affected. For this particular attribute, if the value
is missing, I believe the rule for the default value could be coded similar
to:
============
strNTName = adoRecordset.Fields("sAMAccountName").Value
strDN = adoRecordset.Fields("distinguishedName").Value
intIndex = InStr(LCase(strDN), ",dc=")
strDNSDomain = Mid(strDN, intIndex + 4)
strDNSDomain = Replace(LCase(strDNSDomain), ",dc=", ".")
strUPN = adoRecordset.Fields("userPrincipalName").value & ""
If (strUPN = "") Then
strUPN = strNTName & "@" & strDNSDomain
End If
=========
I would have to do more research to be sure. Finding documentation on how
userPrincipalName works is a pain.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab -
http://www.rlmueller.net
"Pictor" <Pictor RemoveThis @discussions.microsoft.com> wrote in message
news:D1F46719-BA5B-476B-A3FF-8C4D6C89C3B6@microsoft.com...
> Really Thank You!
>
> You can't know how userful has been this answer! ^_^
>
>
> Now I should READ that attribute.... and this is a bigger problem
> With an ADO connection i cannot use it as an output attributes ("SELECT
> userPrincipalName ...") but only in the WHERE clause.
>
> I don't know if is possible to read this attributes or if it is an ADO
> problem...
>
> I think I'll open another thread about it
>
> "Babu VT" wrote:
>
>> Hi Pictor,
>>
>> Look for : "userPrincipalName"
>>
>> Check this link for list of all LDAP attributes.
>> http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.htm
>>
>> rgds
>> Babu
>>
>> "Pictor" <Pictor RemoveThis @discussions.microsoft.com> wrote in message
>> news:1D8B4588-8DA4-43C7-95CB-FCB4F3AB40D7@microsoft.com...
>> > Someone could please tell me which is the Attribute of the Active
>> > Directory
>> > Users that contains the User Account Name?
>> >
>> > I can found only the extended name of a user, using the properties
>> > "Name,
>> > surName, givenName"; but they contain the name as "John JS Smith" (or
>> > something similar) and I still cannot found the one with the User Logon
>> > Name.
>> >
>> > I thought it was the "sAMAccountName" .... but it is not that!
>> >
>> > I need the username that is used to login in Windows (and in the
>> > domain).
>> >
>> > Any suggestions?
>> >
>> > Thanks a lot!
>>
>>
>> >> Stay informed about: Login Name from Active Directory