Geeks With Blogs
Molnar Tibor blog

Update: g. mipa gave me a much simplier solution:

PSSvcResource.Resource myRes = new PSSvcResource.Resource();
GUID currUserID = new GUID(myRes.GetCurrentUserUid());

My bad. Thank you!

Obsolete:

 Can be done by:

  • Get the current user from using the WSS 3.0 API
  • Build the Microsoft.Office.Project.Server.Library.Filter instance using the current user's name
  • Call the ReadResources method of the Resource PSI web service

PSSvcResource.ResourceDataSet resourceDs = new PSSvcResource.ResourceDataSet();

// Create Filter
PSLibrary.Filter resourceFilter = new Microsoft.Office.Project.Server.Library.Filter();
resourceFilter.FilterTableName = resourceDs.Resources.TableName;
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName,resourceDs.Resources.RES_UIDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));
resourceFilter.Fields.Add(new PSLibrary.Filter.Field(resourceDs.Resources.TableName, resourceDs.Resources.RES_IDColumn.ColumnName, PSLibrary.Filter.SortOrderTypeEnum.None));

// Obtain context of current site and user.
SPWeb web = SPContext.Current.Web;
SPUser user = web.CurrentUser;

//Get the user data from the PS database PSLibrary.Filter.FieldOperator existingResource = new PSLibrary.Filter.FieldOperator(PSLibrary.Filter.FieldOperationType.Equal, resourceDs.Resources.RES_NAMEColumn.ColumnName, user.Name);
resourceFilter.Criteria = existingResource; string filterXml = resourceFilter.GetXml();
resourceDs = PSSvcResource.ReadResources(filterXml, false);
if (resourceDs.Resources.Count >= 1)
{
 return resourceDs.Resources[0].RES_UID;
}
else throw new ApplicationException("Current user was not found in project server database");

Posted on Wednesday, February 6, 2008 12:35 AM SharePoint 2007 | Back to top


Comments on this post: Project Server 2007 PSI: Find out the GUID of the cuurent user

# re: Project Server 2007 PSI: Find out the GUID of the cuurent user
Requesting Gravatar...
PSSvcResource.Resource myRes = new PSSvcResource.Resource();
GUID currUserID = new GUID(myRes.GetCurrentUserUid());
Left by g. mipa on Feb 22, 2008 2:57 AM

# re: Project Server 2007 PSI: Find out the GUID of the cuurent user
Requesting Gravatar...
Thnx man! I updated this post.
Left by Tibor Molnar on Feb 26, 2008 7:24 PM

Your comment:
 (will show your gravatar)


Copyright © Molnar Tibor | Powered by: GeeksWithBlogs.net