4 Replies Latest reply on Jul 12, 2017 3:20 PM by mbaillargeon

    How to add active directory subscriber to notification

    mbaillargeon

      Hi Guys,

       

      I need to add a subscriber to a notification. I'm using PI Server 2016 R2.

       

      The subscriber name is in an attribute of the target element. The subscriber is in AD and not a NotificationContact. I'm looking at the SANotification.Subscribers.Add() method but I don't understand how to do that. It seems the only option is to add a NotificationContact and not an AD contact.

       

      Thanks!


      Marc

        • Re: How to add active directory subscriber to notification
          pmartin

          Hi Marc,

           

          You should be able to access AD contacts as AFContacts provided you have your server's AFActiveDirectoryProperties set up.  As an example, I searched for myself and found my AD Contact on the domain like so:

           

          //Verify that the domain information I have is correct
          AFActiveDirectoryProperties a = server.GetActiveDirectoryProperties();
            Console.WriteLine(a.AccountName);
            Console.WriteLine(a.DomainController);
          
            //AFContact
            AFContact c = AFContact.FindContact(server, "Paul Martin");
          //Verify that I found the right "Paul Martin" by checking my department
            Console.WriteLine(c.Department);
          

           

          If those properties returned from GetActiveDirectoryProperties are not correct, you can change them and then use server.SetActiveDirectoryProperties( AFActiveDirectoryProperties properties ).

           

          Once you have the AFContact, you can add a NotificationContactTemplate which can be used by your Notifications:

          server.NotificationContactTemplates.Add(c, "Me");