none
Accessing Project Server groups RRS feed

  • Question

  • I'm trying to programmatically access Project Server 2010 user groups. I'm trying to do by this example:

    http://social.msdn.microsoft.com/Forums/en-US/project2010custprog/thread/e54582f4-1d81-4a46-a64d-a27dce69441d

    but no luck.

    1. problem:

    If I use:

    SvcSecurity.Security MySecurity = SvcSecurity.Security();

    Because Security is an interface, it can not be instantiated. How did they did it in example?

    2. problem:

    Ok, then I used something this:

    SvcSecurity.SecurityClient tSecurity = new SvcSecurity.SecurityClient();

    Her I get an error: "Could not find default endpoint element that references contract 'SvcSecurity.Security' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

    Where do I go from here?

    3. problem ( if there is solution for 1. or 2. problem)

    I would like to send emails to users in Project Server groups, but how do I get to users names or emails programmatically?


    Thursday, November 22, 2012 3:06 PM

Answers

  • Hi Mario,

    if you want to send email to all the users of the group, You can use the security web service to read the Groups using the ReadGroup method  & then loop through the records in Securitydataset 's Group Memebrs Table (as I remember) to get the RES_GUID.
    http://msdn.microsoft.com/en-us/library/office/gg220696(v=office.14).aspx
    Once you have this information, You can call either  Stored procedure in reporting database that queries the MSP_EPMResource_UserView to return the email address

    select ResourceEmailAddress from MSP_EpmResource_UserView
    WHERE ResourceUID = '300CA61F-2CED-48B6-A9D7-0072D791FDA0' 

    or call the Resource Web services to get the Resource email address.
    http://msdn.microsoft.com/en-us/library/office/websvcresource_di_pj14mref(v=office.14).aspx

    Once you have all this information, You can use the SPUtility.Sendemail
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail(v=office.14).aspx

    Hope that helps.


    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82


    Friday, November 23, 2012 9:03 AM
  • I am very grateful for all your help.

    Ray, I had no luck with configuring wcf, I have problems with endpoints, simply cannot find what's wrong.

    But, Amit gave me a great idea. Why use wcf in the first place when I can fetch everything directly from database!

    This is SQL for fetching emails of users of a Project Server group:

    SELECT [WRES_EMAIL]
    FROM [ProjectServer_Published].[dbo].[MSP_RESOURCES]
    WHERE RES_SECURITY_GUID IN (
        SELECT [WRES_GUID]    
        FROM [ProjectServer_Published].[dbo].[MSP_WEB_SECURITY_GROUP_MEMBERS]
        WHERE WSEC_GRP_GUID = (
            SELECT [WSEC_GRP_GUID]   
            FROM [ProjectServer_Published].[dbo].[MSP_WEB_SECURITY_GROUPS]
            WHERE WSEC_GRP_NAME = 'GroupName'))

    On blog:

    http://sharepoint1on1.blogspot.com/2012/11/project-server-2010-send-email-to.html

    Thanks once again!

    • Marked as answer by Mario Zagreb Wednesday, November 28, 2012 12:33 AM
    Wednesday, November 28, 2012 12:33 AM

All replies

  •  Hi Mario, there is an example online where I pulled this routine from to set up the end points. It is from the WCFConsoleApplication. You'll have to compile the project server services DLL to contact the PSI through the WCF and then do something like this:

    private static void SetClientEndpoints(Uri pwaUri)
            {
                try
                {
                    const int MAXSIZE = 500000000;

                    // Set the final part of the URL address of the
                    // front-end ProjectServer.svc router.
                    const string svcRouter = "_vti_bin/PSI/ProjectServer.svc";

                    pwaUrl = pwaUri.Scheme + Uri.SchemeDelimiter + pwaUri.Host + ":"
                        + pwaUri.Port + pwaUri.AbsolutePath;
                    pwaUrlnoport = pwaUri.Scheme + Uri.SchemeDelimiter + pwaUri.Host
                        + pwaUri.AbsolutePath;

                    Console.WriteLine("URL: {0}", pwaUrl);

                    // Create a basic binding that can be used for HTTP or HTTPS.
                    BasicHttpBinding binding = null;

                    if (pwaUri.Scheme.Equals(Uri.UriSchemeHttps))
                    {
                        // Initialize the HTTPS binding.
                        binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                    }
                    else
                    {
                        // Initialize the HTTP binding.
                        binding = new BasicHttpBinding(
                            BasicHttpSecurityMode.TransportCredentialOnly);
                    }

                    binding.Name = "basicHttpConf";
                    binding.SendTimeout = TimeSpan.MaxValue;
                    binding.MaxReceivedMessageSize = MAXSIZE;
                    binding.ReaderQuotas.MaxNameTableCharCount = MAXSIZE;
                    binding.MessageEncoding = WSMessageEncoding.Text;
                    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

                    // The endpoint address is the ProjectServer.svc router for all public PSI calls.
                    EndpointAddress address = new EndpointAddress(pwaUrl + svcRouter);

                    projectClient = new backendProject.ProjectClient(binding, address);
                    projectClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                        = TokenImpersonationLevel.Impersonation;
                    projectClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;

                    queueSystemClient = new backendQueueSystem.QueueSystemClient(binding, address);
                    queueSystemClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                        = TokenImpersonationLevel.Impersonation;
                    queueSystemClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;

                    //new CF client
                    customFieldsClient = new backendCustomFields.CustomFieldsClient(binding, address);
                    customFieldsClient.ChannelFactory.Credentials.Windows.AllowedImpersonationLevel
                        = TokenImpersonationLevel.Impersonation;
                    customFieldsClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;
                }
                catch (Exception ex)
                {
                    string error = ex.Message.ToString();
                }

            }//end setclientendpoints

    So for each service you want you have to set up the client. I needed wcf services from the queue, project and custom fields so instantiated those above.

    good luck!

    Ray


    Ray Letts Arbutus Solutions

    Thursday, November 22, 2012 5:16 PM
  • Thanks Ray, will try this.

    Is there a way to send an email to all users of Project Server group?

    Friday, November 23, 2012 8:01 AM
  • Hi Mario,

    if you want to send email to all the users of the group, You can use the security web service to read the Groups using the ReadGroup method  & then loop through the records in Securitydataset 's Group Memebrs Table (as I remember) to get the RES_GUID.
    http://msdn.microsoft.com/en-us/library/office/gg220696(v=office.14).aspx
    Once you have this information, You can call either  Stored procedure in reporting database that queries the MSP_EPMResource_UserView to return the email address

    select ResourceEmailAddress from MSP_EpmResource_UserView
    WHERE ResourceUID = '300CA61F-2CED-48B6-A9D7-0072D791FDA0' 

    or call the Resource Web services to get the Resource email address.
    http://msdn.microsoft.com/en-us/library/office/websvcresource_di_pj14mref(v=office.14).aspx

    Once you have all this information, You can use the SPUtility.Sendemail
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail(v=office.14).aspx

    Hope that helps.


    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82


    Friday, November 23, 2012 9:03 AM
  • I am very grateful for all your help.

    Ray, I had no luck with configuring wcf, I have problems with endpoints, simply cannot find what's wrong.

    But, Amit gave me a great idea. Why use wcf in the first place when I can fetch everything directly from database!

    This is SQL for fetching emails of users of a Project Server group:

    SELECT [WRES_EMAIL]
    FROM [ProjectServer_Published].[dbo].[MSP_RESOURCES]
    WHERE RES_SECURITY_GUID IN (
        SELECT [WRES_GUID]    
        FROM [ProjectServer_Published].[dbo].[MSP_WEB_SECURITY_GROUP_MEMBERS]
        WHERE WSEC_GRP_GUID = (
            SELECT [WSEC_GRP_GUID]   
            FROM [ProjectServer_Published].[dbo].[MSP_WEB_SECURITY_GROUPS]
            WHERE WSEC_GRP_NAME = 'GroupName'))

    On blog:

    http://sharepoint1on1.blogspot.com/2012/11/project-server-2010-send-email-to.html

    Thanks once again!

    • Marked as answer by Mario Zagreb Wednesday, November 28, 2012 12:33 AM
    Wednesday, November 28, 2012 12:33 AM
  • Hi Mario,

    It may work out using the SQL query againest the Published database but please note that  As per Microsoft support, Developers are strongly discouraged from directly accessing the Draft, Published, or Archive Project Server database through Microsoft SQL Server queries.
    Making direct changes in the Project Server database tables can damage referential integrity and interfere with database access through the Project Server Queuing Service.

    Applications that directly access the Draft, Published, or Archive database also are dependent on the database schemas, which can change in service packs or later versions of Project Server 2010. Furthermore, applications that directly access the databases lose the built-in Project Server security, common business logic, tracking, audits, error checking, reporting, workflow, and other features. You would likely need to rewrite such an application for Project Server 2010 updates. 
    http://msdn.microsoft.com/en-us/library/ms504195.aspx

    The best suitable option is to use the Security web service & get the group detaial & later once you have the RESource GUID, You can query the Reporting database to avoid another PSI call to Resource Web service.

    Hope that helps.


    If you found this post helpful, please “Vote as Helpful”. If it answered your question, please “Mark as Answer”. Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82


    Wednesday, November 28, 2012 5:15 AM