Tanmay
Tanmay

Reputation: 335

Office Add-ins : Windows Authentication (Get User Name who Logged into Machine)

Friends,

I need some help on Word API Authentication.

Scenario:

Our articles has meta data which contains who can work on the articles (User1, User2), we need to know user_name (window's id) who logged into the machine so that we can authenticate the users against article metadata without asking them to log-in each time.

Workflow:

  1. Article Creator Process is responsible for creating the document. This process will create word document and will be transferred to the user.
  2. Article processor is adding custom xml part into document such as User Name, Document ID etc.
  3. Authentication Rule is simple here. If article metadata contains your name then only you can work else not.
  4. We need to match article meta data name with user who is opening the document. So here we need to know who log-ed into the machine.
  5. How we can get this information for Online and Offline ?
  6. We don't want our desktop users to enter the credentials again and again. For desktop which is (90% users will use desktop) is should be pretty straight forward, get user name and match it with article metadata.

Appreciate any help on this, any alternative solutions to handle this are most welcome.

Upvotes: 0

Views: 1102

Answers (1)

Michael Zlatkovsky
Michael Zlatkovsky

Reputation: 8670

There is no way to find out the current user's username. You can get the unique ID of the user in terms of a GUID-like entity, though, so I suppose you could store the user GUID into the custom XML part instead. The GUID corresponds to the Microsoft account or OrgID identity of the user.

See https://msdn.microsoft.com/en-us/library/office/jj164035.aspx for more info, particularly the "To load a test license from your Visual Studio project" section that describes the structure of the validation token.

Alternatively, if you can trust your users (i.e., it's just identification, not authentication), have them type in their name once, and then store it in the browser's localStorage.

Upvotes: 1

Related Questions