Access current user's manager name in the console application ( through Client object model)
Hi Guys,
Is there any way to retrieve current logged-in user's Manager name in the console application.
As I don't have access to the server where SharePoint 2010 is installed so I wanted to access through client object model.
arun singh
Unfortunately, you can't use CSOM to do this in SharePoint 2010 (you can in SharePoint 2013!), but you CAN use the User Profile Service .asmx web service to accomplish this. You need to call the
GetUserProfileByName method exposed
in the http://<yourServerName>/_vti_bin/UserProfileService.asmx web service. Pass in the user name for the current user and Manager will be one of the properties that is returned.
Here is a link to a blog post with example code.
Please mark my reply as helpful (the up arrow) if it was useful to you and please mark it an answer (the check box) if it answered your question! Thank you!
Danny Jessee | MCPD - SharePoint Developer 2010 | MCTS - SharePoint 2010, Configuring
Blog: http://dannyjessee.com/blog | Twitter: @dannyjessee
Similar Messages
-
The below mentioned code works sometimes and doesn't most of the time. What is the real best way to update multi select managed metadata fields?
Microsoft.SharePoint.Client.File file = site.GetFileByServerRelativeUrl("/sites/myspsite/Documents/Presentation2.pptx");
clientContext.Load(file);
clientContext.ExecuteQuery();
ListItem currentItem = file.ListItemAllFields;
clientContext.Load(currentItem);
clientContext.ExecuteQuery();
currentItem["Country"] = "-1;#India|1d13cfe9-d6f4-4bd3-a6c7-4b46a81f2a96;#-1;#China|9c1dff73-82db-44b1-8d70-f4258dd24e47;#-1;#USA|b9295c0b-67d4-4dc5-99d4-e88af888de48";
currentItem["Title"] = "Demo Doc";
currentItem.Update();
clientContext.ExecuteQuery();
file.CheckIn("test check-in", CheckinType.MajorCheckIn);
clientContext.ExecuteQuery();
Anuradha!!Hi,
Here are two blog for your reference:
How to Work with Managed Metadata Columns by Using the SharePoint Client Object Model
http://blogs.msdn.com/b/sharepointdev/archive/2011/11/18/how-to-work-with-managed-metadata-columns-by-using-the-sharepoint-client-object-model-kaushalendra-kumar.aspx
SharePoint 2010 Code Tips – Setting a Managed Metadata Field with the Client Object Model
http://sharepointfieldnotes.blogspot.com/2011/08/sharepoint-2010-code-tips-setting.html
Best Regards
Dennis Guo
TechNet Community Support -
Hi,
I want to fetch the list of users who all are having full access to the sharepoint list using client object model with .Net
Please let me know if any property for the user object or any other way to get it.
Thanks in advance.Here you are complete code i created from some years it lists all groups and users, you can just add a check in the permissions loop to see if it is equal to Full Control.
Private void GetData(object obj)
MyArgs args = obj as MyArgs;
try
if (args == null)
return; // called without parameters or invalid type
using (ClientContext clientContext = new ClientContext(args.URL))
// clientContext.AuthenticationMode = ClientAuthenticationMode.;
NetworkCredential credentials = new NetworkCredential(args.UserName, args.Password, args.Domain);
clientContext.Credentials = credentials;
RoleAssignmentCollection roles = clientContext.Web.RoleAssignments;
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
ListViewItem lvigroup;
ListViewItem.ListViewSubItem lvsigroup;
clientContext.Load(roles);
clientContext.ExecuteQuery();
foreach (RoleAssignment orole in roles)
clientContext.Load(orole.Member);
clientContext.ExecuteQuery();
//name
//MessageBox.Show(orole.Member.LoginName);
lvi = new ListViewItem();
lvi.Text = orole.Member.LoginName;
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = orole.Member.PrincipalType.ToString();
lvi.SubItems.Add(lvsi);
//get the type group or user
// MessageBox.Show(orole.Member.PrincipalType.ToString());
if (orole.Member.PrincipalType.ToString() == "SharePointGroup")
lvigroup = new ListViewItem();
lvigroup.Text = orole.Member.LoginName;
// args.GroupsList.Items.Add(lvigroup);
DoUpdate1(lvigroup);
Group group = clientContext.Web.SiteGroups.GetById(orole.Member.Id);
UserCollection collUser = group.Users;
clientContext.Load(collUser);
clientContext.ExecuteQuery();
foreach (User oUser in collUser)
lvigroup = new ListViewItem();
lvigroup.Text = "";
lvsigroup = new ListViewItem.ListViewSubItem();
lvsigroup.Text = oUser.LoginName;
lvigroup.SubItems.Add(lvsigroup);
//args.GroupsList.Items.Add(lvigroup);
DoUpdate1(lvigroup);
// MessageBox.Show(oUser.LoginName);
RoleDefinitionBindingCollection roleDefsbindings = null;
roleDefsbindings = orole.RoleDefinitionBindings;
clientContext.Load(roleDefsbindings);
clientContext.ExecuteQuery();
//permission level
lvsi = new ListViewItem.ListViewSubItem();
string permissionsstr = string.Empty;
for (int i = 0; i < roleDefsbindings.Count; i++)
if (i == roleDefsbindings.Count - 1)
permissionsstr = permissionsstr += roleDefsbindings[i].Name;
else
permissionsstr = permissionsstr += roleDefsbindings[i].Name + ", ";
lvsi.Text = permissionsstr;
lvi.SubItems.Add(lvsi);
// args.PermissionsList.Items.Add(lvi);
DoUpdate2(lvi);
catch (Exception ex)
MessageBox.Show(ex.Message);
finally
DoUpdate3();
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation -
Current User Filter not available in the Add Web Parts list - Sharepoint 2007
Hi everybody,
I'm trying to build a copy (or auto-populate) function on a list.
I did all the coding changes, now I need to add a web part to my list called Current User Filter.
Problem is, the Current User Filter is not in the Web Part list at all!
How can I add it ? I looked in the Central Admin Panel and did not see anything.
Thanks in advance!What version of SharePoint are you using? I think that this is s MOSS webpart, so if you're using the WSS version of the product, you're probably out of luck.
Steven Andrews
SharePoint Business Analyst: LiveNation Entertainment
Blog: baron72.wordpress.com
Twitter: Follow @backpackerd00d
My Wiki Articles:
CodePlex Corner Series
Please remember to mark your question as "answered" if this solves (or helps) your problem. -
Unable to get the SharePoint 2013 List names using Client object model for the input URL
Please can you help with this issue.
We are not able to get the SharePoint 2013 List names using Client object model for the input URL.
What we need is to use default credentials to authenticate user to get only those list which he has access to.
clientContext.Credentials = Net.CredentialCache.DefaultCredentials
But in this case we are getting error saying ‘The remote server returned an error: (401) Unauthorized.’
Instead of passing Default Credentials, if we pass the User credentials using:
clientContext.Credentials = New Net.NetworkCredential("Administrator", "password", "contoso")
It authenticates the user and works fine. Since we are developing a web part, it would not be possible to pass the user credentials. Also, the sample source code works perfectly fine on the SharePoint 2010 environment. We need to get the same functionality
working for SharePoint 2013.
We are also facing the same issue while authenticating PSI(Project Server Interface) Web services for Project Server 2013.
Can you please let us know how we can overcome the above issue? Please let us know if you need any further information from our end on the same.
Sample code is here: http://www.projectsolution.com/Data/Support/MS/SharePointTestApplication.zip
Regards, PJ Mistry (Email: [email protected] | Web: http://www.projectsolution.co.uk | Blog: EPMGuy.com)Hi Mistry,
I sure that CSOM will authenticate without passing the
"clientContext.Credentials = Net.CredentialCache.DefaultCredentials" by default. It will take the current login user credentials by default. For more details about the CSOM operations refer the below link.
http://msdn.microsoft.com/en-us/library/office/fp179912.aspx
-- Vadivelu B Life with SharePoint -
I only recently learned/read about SharePoint's JavaScript Client Object Model. I'm reading online trying to figure this out but not having much luck.
On newform.aspx (and dispform.aspx) I want to get the
current list,
the last item created, and it's attachments. I now the CAML query I need to get the last item created, but first I have to get the current list and I am not sure how to do that.
I tried this but it returns null:
SP.ListOperation.Selection.getSelectedList()Hi,
For your issue, you can get the list name from the new form url and retrieve the list last created item :
https://social.msdn.microsoft.com/Forums/office/en-US/b90a64f8-2255-41b0-9d91-78335dd4a4cf/get-list-name-from-list-url-through-javascript?forum=sharepointdevelopmentprevious
http://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx
Best Regards,
Eric
Eric Tao
TechNet Community Support -
Get current loggedin user using silverlight client object model SharePoint 2010?
Hello,
How can i get the current loged in user of sharepoint 2010 in silverlight4.XX version by programtically in C#?
Thanks
Lovkesh PatelHi,
ClientContext clientContext = ClientContext.Current;
clientContext.Load(clientContext.Web, s => s.CurrentUser);
clientContext.ExecuteQueryAsync((sender, args) => {
var currentUser = clientContext.Web.CurrentUser; }, null);
For more information:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.currentuser.aspx and
http://stackoverflow.com/questions/3441794/retrieve-current-user-login-in-sharepoint-from-a-silverlight-application
Hope this helps you
Senior Sharepoint Developer,STS [email protected] -
Trying to use Web LCID property to get the List name in client object Model
Hi ,
I am trying to change the "Personal Documents" list NoCrawl property under MySite using SharePoint Client Object Model. As we use web.Lists.GetByTitle("Personal
Documents"); method to get the list,but here problem is :for different language List name is in their language.So I tried to use LCID property of the WEB and
have taken key-value pair (PersonalSiteOnet_List_PersonalDocuments) from the resource file for that language from 14 hive.
Example:I have selected Spanish language .there are so many LCID for Spanish language but Microsoft has given only one language pack for Spanish.
Then,My Question is that
"All LCID for Spanish language are using same Spanish language pack dictionary file OR something else"
Hi,
According to your post, my understanding is that your requirement is getting list in different language.
Here are two ways for your reference:
1. We can use getById method instead, so that we can avoid the language issue.
2. We can use an array to store the different list name in different language in you JavaScript code, then use the code snippet below to get the list:
var userLcid =_spPageContextInfo.currentLanguage;
var localizedStrings = {
ListName: {
_1033: "EnglishName",
_3082: "SpanishName"
var listName=localizedStrings.ListName["_" + userLcid];
var list=web.Lists.getByTitle(listName);
More information:
http://msdn.microsoft.com/en-us/library/hh670609.aspx
http://wellytonian.com/2012/11/language-packs-sharepoint-2010/
Best Regards
Dennis Guo
TechNet Community Support -
Start managed server on the console problem
I use the weblogic server 6.1 sp1 on the microsoft NT 4.0 and 2000 server
sp2, But i have a problem.
When i use the default setting to start the administration server and node
managed, Then i try to start the managed server on the console, Then
<2002/1/8 H07B3745?gt; <Error> <NodeManager> <Could not start
server'server622' via Node Manager - reason: '[SecureCommandInvoker: Could
not create a socket to the NodeManager running on host 'myIPAddress:5555' to
execute command 'online null', reason: Connection refused: connect. Ensure
that the NodeManager on host 'myIPAddress' is configured to listen on port
'5555' and that it is actively listening]'>
All of the configuration setting ( include the startWeblogic and
startNodeManagerWeblogic ) is defuault.
But when i install the Sun JDK 1.3.1_20 on those machines, It's fine to
start the managed server on the console, Although it's failure now again, i
don't know why ( coz, i uninstall weblogic and jdk then install it again ).
Anyone have this problem, could tell me how to solve it, Thx.Chris,
I want to be sure I understand because I was a little unclear at the end. You
did successfully get the managed server to start from the console after you
installed jdk1.3.1? Be sure your PATH variable contains the correct java bin
directory. Are you failing again now that you reinstalled WLS and the JDK?
Regards,
Velvet
Developer Relations Engineer
BEA Systems
Chris Chuang wrote:
I use the weblogic server 6.1 sp1 on the microsoft NT 4.0 and 2000 server
sp2, But i have a problem.
When i use the default setting to start the administration server and node
managed, Then i try to start the managed server on the console, Then
<2002/1/8 H07B3745?gt; <Error> <NodeManager> <Could not start
server'server622' via Node Manager - reason: '[SecureCommandInvoker: Could
not create a socket to the NodeManager running on host 'myIPAddress:5555' to
execute command 'online null', reason: Connection refused: connect. Ensure
that the NodeManager on host 'myIPAddress' is configured to listen on port
'5555' and that it is actively listening]'>
All of the configuration setting ( include the startWeblogic and
startNodeManagerWeblogic ) is defuault.
But when i install the Sun JDK 1.3.1_20 on those machines, It's fine to
start the managed server on the console, Although it's failure now again, i
don't know why ( coz, i uninstall weblogic and jdk then install it again ).
Anyone have this problem, could tell me how to solve it, Thx. -
What is the name of the iPhone application that allows me to wirelessly print to my printer?
What is the name of the iPhone application that will let me print to wirelessly to my printer?
I have the same problem just bought a HP Photosmart Plus B210 with a Netgear wireless N Router, Wireless is working great with my Gateway laptop and the Ipad, and 2 iphones. The laptop prints tex and pic's wireless.
I can e mail and print pic's from my i devices and all show wi-fi working great. But when I hit print to print a pic. nothing. If I get the answer I will let you know. -
How to find the Name of the BSP Application Being Invoked?
Hi ,
Is there any FM or method that would return the name of the BSP Application being invoked?
Say i have a method A which is being invoked by 2 BSP Application B and C. How do we determine which BSP is invoking the method A?
Any input on this regard will be of great help.
Thanks and Regards,
PavithraHi,
this methods are not 100% efective but you may try it:
On runtime:
set an external breakpoint in your method A and run your application. When it stops, the debugger has many folders, so press the one marked with "Standard" and in section ABAP stack you see the different call steps that have been executed, including the application that is calling the method.
For this you must activate the new debugger (Utilities --> settings --> ABAP editor --> Debugging)
On development time:
Click on method A and press button Where-used list. In the incomming window press BSP applications.
Hope it helps. -
Quering the database using Client Object Model
Hi,
I have to fetch the list items from a list named "Project Status" and display it in a table using
Client Object model.
The equivalent server side code is:
SPWeb web = SPContext.Current.Web;
SPList list = web.Lists["Project Status"];
DataTable dt1 = new DataTable();
try
if (list.ItemCount > 0)
DataColumn dc;
DataColumn dc1;
dc = new DataColumn("ProjectId", Type.GetType("System.String"));
dc1 = new DataColumn("Project Name", Type.GetType("System.String"));
dt1.Columns.Add(dc);
dt1.Columns.Add(dc1);
DataRow dr;
foreach (SPListItem item in list.Items)
dr = dt1.NewRow();
dr["ProjectId"] = item["ProjectId"];
dr["Project Name"] = item["Project Name"];
dt1.Rows.Add(dr);
Repeater1.DataSource = dt1;
Repeater1.DataBind();
catch (Exception Ex)
throw Ex;
1 more issue what i face is providing two links in the Visual WebPart and their navigate url is based on a condition that is fetched from the database. This corresponding code has to be converted to
Client Object Model.
string user = web.CurrentUser.LoginName;
string userID = user.Split(new char[] { '\\' })[1];
string connString = @"Data Source=NorthWind;Initial Catalog=EmployeeDB;User ID=sa;Password=Newuser123";
string query = "select * from EMPLOYEE_PROFILE";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(query, conn);
try
conn.Open();
DataTable t1 = new DataTable();
using (SqlDataAdapter a = new SqlDataAdapter(cmd))
a.Fill(t1);
DataRow[] dr = t1.Select("PsNo = '" + userID + "'"); //This will select all rows where the Name Column has current user
foreach (DataRow r in dr)
string bU = r["DeputedBU"].ToString();
if (bU == "INS" || bU == "BFS")
lnkPM.NavigateUrl = web.Site.WebApplication.Sites[0].Url + "/Dashboard.aspx";
lnkSummary.NavigateUrl = web.Site.WebApplication.Sites[0].Url + "/DashboardWithHyperlinks.aspx";
else
lnkPM.Visible = false;
lnkSummary.Visible = false;
catch (Exception)
throw;
finally
conn.Close();
Any help would be appreciated.Hi,
According to your post, there would be two questions in this single thread.
It is recommended to post one question in one single thread which will make others easier to focus on one question in one thread.
For the first question, you want to fetch list items and put into a DataTable object using Client Object Model.
To fetch list items from a list using Client Object Model, you can take a look at the code snippet below from MSDN:
http://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx
For the second question, you might need to retrieve the User object and site collections object using Client Object Model.
However, if you can develop a Visual Web Part for your site, it means that you will be able to access the SharePoint Object Model which has more powerful APIs, so there is no
need to use Client Object Model in a Visual Web Part.
Best regards
Patrick Liang
TechNet Community Support -
Unable to Open the HFM application through Workspace
Hi,
Here I am getting below error while i am trying to open the HFM application through Workspace.
I was permitted allowed all IIS (Allow option checked ) but still the error coming i am unable to open my application through workspace , but i am able to do the all thing in HFM via Clien.The error is below
There was some communication error. Response is : http://localhost:19000/hfm/GlobalWorkspaceNav/bpm/modules/com/hyperion/hfm/web/appcontainer/Adf.asp <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>The page cannot be found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<STYLE type="text/css">
BODY { font: 8pt/12pt verdana }
H1 { font: 13pt/15pt verdana }
H2 { font: 8pt/12pt verdana }
A:link { color: red }
A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
<hr>
Please try the following:
Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly.
If you reached this page by clicking a link, contact
the Web site administrator to alert them that the link is incorrectly formatted.
Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
<hr>
Technical Information (for support personnel)
Go to Microsoft Product Support Services and perform a title search for the words HTTP and 404.
Open IIS Help, which is accessible in IIS Manager (inetmgr),
and search for topics titled Web Site Setup, Common Administrative Tasks, and About Custom Error Messages.
</TD></TR></TABLE></BODY></HTML>
"There was some communication error. Response is : http://localhost:19000/hfm/GlobalWorkspaceNav/bpm/modules/com/hyperion/hfm/web/appcontainer/Adf.asp"
"there can be many causes to this error....
1) you should check first of all that the redirection from Apache port 19000 to folder HFM within the IIS is actually working. try hitting http://apacheserver:19000/hfm and make sure you get "hfm" response back.
2) check that ASP is turned on in the IIS ("file / directory not found" suggests that it isnt)
3) check what URL you used when you created the application or when you registered it with shared services as the "Financial Management Web Server URL for Security". It should normally be http://apacheservername:19000/hfm. If you did this wrong then re-register it with shared services via Navigate->Administer->Classic Application Administration->Consolidation Administration.
4) check that the application was registered with Shared Services in the first place.
5) make sure that on the HFM web server, the HFM application server/cluster is properly registered
6) stop and restart all services and test again...
7) try not to use "localhost" but proper fully qualified domain names "servername.mydomain.com" wherever possible. you will have less problems. the only place where you should use a non qualified name is in Relational Content links... see the HFM readme. -
Hello All -
I am trying to add a user to a SharePoint site using PowerShell like below:-
New-SPUser -UserAlias MyDomain\jan20a -Web http://SPServer/sites/MySite
If I execute the above more than once, SharePoint does not throw that user already exists or something. This is not the same behavior in AD/Exchange PowerShell cmdlets.
Also, even the client object model behaves the same way.
Another interesting thing I noticed, I tried to remove a user from group in which the user was not part of it at all and still no error..!!
Looks like SharePoint does not care of invalid input and just ignores it.
Can anyone please confirm this and also the reason behind it ?It's not really invalid input, since the user exists and that is how SharePoint behaves (will behave same way in browser). Try to input a user that and misspell the name, e.g. say you didn't have a MyDomain\Jan21a, then try to use same script above,
only with invalid data. It will bark at you. Or try using a web that it cannot find, one that does not exist. You'll get what I like to call, the red badge of courage if you enter invalid data.
you can test that sharepoint will let you enter a user twice in the browser, and nothing bad comes from it. Powershell is just unable to tell that the user was not in the site, when you removed it the second time.
Hope that confirms it, if it does please mark this reply accordingly. thanks
Stacy Simpkins | MCSE SharePoint | www.sharepointpapa.com -
Enable anonymous access for Javascript Client Object Model
In SharePoint 2010 it was possible to use the Javascript Client Object Model with anonymous access enabled by removing "GetItems" from the ClientCallableSettings.AnonymousRestrictedTypes.
In SharePoint 2013 however, it seems that an extra security barrier has been implemented. Trying to use the Javascript Client Object Model results in the following message: "Access denied. You do not have permission to perform this action or access this
resource."
After this I went on to do a little research, and it appears that Javascript Client Object Model actually relies on the REST API (please correct me if I'm mistaken), and the REST API also doesn't seem to work as an anonymous user.
So I'm in the dark here. I can't imagine that SharePoint 2013 (so heavily relying on the client object model) can't be used with anonymous access. I've also found very little documentation on anonymous access in combination with SharePoint 2013.
So, how do I enable the Javascript Client Object Model to be used with anonymous access enabled?
P.S. Needless to say, my web application is enabled for anonymous access and so is my site collection.There are really 4 things you need to do to enable anonymous access:
1. In web application level, enable anonymous.
2. In site collection level, make sure anonymous access Entire Website.
3. In Web level, set Full Permission Masks, till here, you're able to anonymously access REST APIs.
# Enable Anonymous access
$web = Get-SPWeb $url
if($web -ne $null)
Write-Host
Write-Host -ForegroundColor Yellow "Enabling Anonymous access on:" $web.Url
Write-Host
$web.AnonymousState = "On"
Write-Host -ForegroundColor Yellow "AnonymousState set to:" $web.AnonymousState
$web.AnonymousPermMask64 = "FullMask"
Write-Host -ForegroundColor Yellow "AnonymousPermMask64 set to:" $web.AnonymousPermMask64
$web.Update()
Write-Host
Below are the things to enable anonymous client object model APIs:
4. In web application level, Require Use Remote Interfaces Permission - uncheck it.
5. In web application level, Anonymous Restricted Types, remove all of them:
$app.ClientCallableSettings.AnonymousRestrictedTypes.RemoveAll()
Maybe you are looking for
-
I am currently developing a solution to communicate with a web service using UTL_DBWS and PL/SQL. I am able to successfully connect and communicate with http://www.oracle-base.com/webservices/ and a web service I created using JDeveloper. We are curr
-
How set or create an autonumeric ID column in access.
I want to create or set the properties of the column for set an autonumeric id, I have a vi that send data to the DB but I need this column. Solved! Go to Solution.
-
Satellite A505 Doesn't Recognize HP Printer
My Satellite A505 laptop doesn't recognize my HP Color LaserJet 2550L printer, when I connect them with a USB line. I tried going to the HP site to download the drive for the 2550L, but that site said Windows 7 already had it! Suggestions? Solved! G
-
Environment keyboard- how to make it work ?
anybody have the multi step procedure handy ? I used to be able to do this on my previous copy of Logic (v3). I know its possible. Wanting to use the keyboard both for inputing notes and watching playback of certain MIDI files. Cheers
-
Special Effects Camera Troubles
My camera alone is working fine but my main problem is when I want to use special effects like in Photo Booth. It is either scattered parts of what is in the camera or just black blobs. I have already been to the Genius Bar so I don't know what to do