You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Finding Windows NT user name and display name

posted on August 28, 2017

Using the SDK, I am able to get the SID of all Windows NT accounts in Laserfiche using  

 Trustee.EnumAllWindowsAccounts(session)

but I can't figure out how to get the User Name and the Display Name for that user.  How can I do this?

0 0
replied on August 28, 2017

Try the AccountReference class:

AccountReference accountRef = new AccountReference(sid, session);
string accountName = accountRef.AccountName;

 

1 0
replied on August 28, 2017

That gave me the user name but not the display/friendly name (the LdapFriendlyName property is empty).  Any idea how I can get that?

0 0
replied on August 28, 2017

Contact the domain directly to get that information (I don't think it is exposed anywhere in Laserfiche.RepositoryAccess):

using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
    using (Principal trustee = Principal.FindByIdentity(ctx, IdentityType.Sid, session.UserIdentity.ToString()))
    {
        Console.WriteLine(trustee.DisplayName);
    }
}

Note: this can be a slow operation.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.