Get id? current user such as SharePoint?

I am on a client site where they have an application that started in SharePoint and is slowly moving to a very custom ASP.NET application. Some of their data items are still hosted on SharePoint lists, two of which are currently in doubt, these are some Notes and Tasks (fairly simple data items in their SharePoint setup, nothing special about them). One of the things I need to do in ASP.NET is to automatically create some new elements for these lists and add them from the code.

So far it's pretty easy. I found an existing web part that handled editing for these elements, attached a debugger to it, tracked how it got its values ​​and what it added to the list, etc. However, one of the fields added to the list item is completely obvious. In the existing web part user interface, the field is as follows:

Assigned to field

Essentially, this is a field for entering a user from the current Windows domain. The book icon opens a pop-up window that allows the user to search for a name, etc. In my current testing, I am running a local administrator on the development machine. So I'm just looking for the “admin” in the pop-up window, and it fills in the field [[machine name] \ Administrator ”, as expected. Then, when debugging, the value that is retrieved from the field and entered into the SharePoint list item is "1", not a name or something like that.

I assume that "1" is the identifier of the local administrator account. In the end, it makes sense. But my question is: how can I get this identifier for the current registered user in the code? I found code to get the current username, but not any numeric number (even if it's a string).

In addition, this will not occur in the context of an ASP.NET application. There is also a WPF client application for laptops that will generate these list items and synchronize them with the server when connected. I am currently working on the basis that the client user will be registered with the proper domain account known to the server.

I guess this is pretty easy, I just haven't stumbled on what I need yet.

+5
1

, :

int userId = SPContext.Current.Web.CurrentUser.ID;

, , SharePoint . WPF, WebService SharePoint, . SharePoint, , : -)

+6

All Articles