Welcome to ServerForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Login Name from Active Directory

 
   Windows Server (Home) -> Windows Server Scripting RSS
Next:  CSCRIPT in VBS  
Author Message
Pictor

External


Since: Jul 26, 2006
Posts: 1



(Msg. 1) Posted: Wed Jul 26, 2006 3:59 am
Post subject: Login Name from Active Directory
Archived from groups: microsoft>public>windows>server>scripting (more info?)

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! Sad

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 
Back to top
Login to vote
Babu VT

External


Since: Jul 25, 2006
Posts: 17



(Msg. 2) Posted: Wed Jul 26, 2006 4:48 pm
Post subject: Re: Login Name from Active Directory [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.TakeThisOut@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! Sad
>
> 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 
Back to top
Login to vote
Richard Mueller

External


Since: Jun 03, 2006
Posts: 31



(Msg. 3) Posted: Thu Jul 27, 2006 11:19 am
Post subject: Re: Login Name from Active Directory [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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! Very Happy
>
> You can't know how userful has been this answer! ^_^
>
>
> Now I should READ that attribute.... and this is a bigger problem Sad
> 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 Sad
>
> "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! Sad
>> >
>> > 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 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
VBS to insert user from active directory to local group de.. - Please, How can I insert an user from active directory in a local group in a desktop using vbs.

script to change path of home directory for all users in d.. - for a windows nt domain how would i change the path of the home directory with a script. same path for all users

script to login to windows domain - I need to find a way to login to a AD domain. That is, my laptop is in some workgroup, and I want to have a script to logon to a AD domain given three pieces of info: login, domain name, passwd. I do not want any setting on the laptop to be changed..

minimum rights needed to run script against active directory - hi all - does someone know what the minimum rights in ad are for someone to be able to run a script which enumerates the members of a global group? the group is in an ou for which the user has full control rights; however, he cannot run the script. the....

how to create a specific folder in each users directory - i want to create a particular folder in every users mailbox (M:\user) drive. i want any kind of windows script it will fulfil my requirement. is it safe if i create a folder through M:\ drive? its a urgent :) help is appritiated.
   Windows Server (Home) -> Windows Server Scripting All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]