c# - How do I get the account name from UserPrincipal? -


i using active directory login in 1 of winforms applications. userprincipal object i'm not sure how proper accountname object? can see there samaccountname same account name states old versions of windows. how proper account name no mather old or new windows systems?

this code use object

if (adusername.length > 0)     context = new principalcontext(contexttype.domain, adserver, null,  adusername, aduserpassword); else     context = new principalcontext(contexttype.domain, adserver);  userprincipal.findbyidentity(context, account) 

samaccountname is "account name" used in windows before active directory introduced.

it's "legacy" in has been supplemented additional info - "distinguished name" in ldap context etc. - is windows account name ("short name") - , it's still mandatory field new user being created - use it!

see user naming attributes more details on name used in ad context.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -