JMCooper
JMCooper

Reputation: 77

XPages retrieve current logged on Active Directory User

Can anyone advise how I might be able to retrieve the current logged on Active Directory user?

I have been looking through how this would normally be done in JSF:

javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getRequest().getUserPrincipal()

Unfortunately this always seems to retrieve the domino user.

Upvotes: 0

Views: 882

Answers (2)

mark
mark

Reputation: 11

If you use the LDAP distinguishedName attribute as Domino suggests you may be able to get an LDAP authenticated user's name using a formula like this:

@If(
 @NameLookup([NoUpdate]:[NoSearching]; @UserName ;"Fullname")!=""; @Name([CN];@UserName);
 @NameLookup([NoUpdate]:[TrustedOnly]; @UserName; "cn")=@Name([CN];@UserName);  @NameLookup( [NoUpdate]:[TrustedOnly]; @UserName ;"displayName");
 @UserName );

But in Xpages I think you'll need to use Java to do an LDAP lookup.

Upvotes: 1

stwissel
stwissel

Reputation: 20384

There is no such thing as "Active Directory User". When you authenticate with a Domino server you always get a "Domino user" regardless of what you authenticated your user against. I would suspect that the AD is delivering a "Domino user" name on authentication which can look different from the AD credentials depending on your configuration. So your course of action would then be a LDAP lookup into AD to get the matching AD user.

Upvotes: 2

Related Questions