Can I Return Contact Objects That Have a SIP Address?

OK, this is an interesting one, simply because it’s a situation we never gave a thought to, and yet it’s apparently something that crops up in real life all the time; after all, we had three different people ask us this very same question. This particular question – Can I return contact objects that have a SIP address – revolves around this scenario: you have some contact objects in Active Directory. Keep in mind that these aren’t the contact objects that get created when you install Lync Server; instead, these are contact objects that represent real people. (Or at least that typically represent real people.) In other words, these are contact objects you might create by going into Active Directory Users and Computers, right-clicking an OU, pointing to New, and then clicking Contact.

Got that? OK, now suppose you use a script, or maybe Active Directory Users and Computers' Attribute Editor, to give one of these contacts a SIP address; that is, you assign a value to the contact's msRTCSIP-PrimaryUserAddress attribute. The question is this: is there any way to return a list of contacts that have been assigned a SIP address?

To tell you the truth, this wasn’t just an interesting question; it was a flat-out exciting question. That’s because we had no idea what the answer would be: would there be an easy way to return these contacts or would we have to write some convoluted Active Directory search script in order to retrieve this information? Either way, the suspense was almost unbearable.

Note. And yes, the fact that we find a question like "Can I return contact objects that have a SIP address?" to be incredibly exciting pretty much tells you everything you need to know about the life of a technical writer at Microsoft.

And the answer is (drumroll, please): yes, you can return information about contact objects that have been assigned a SIP address; in fact, by default, those contacts get returned any time you run the Get-CsUser cmdlet. Of course, in that case, they’re mixed in with all your other Lync Server users; by default Get-CsUser makes no distinction between contact accounts and user accounts. If you’d like a list of just the contacts who have a SIP address then you'll need to use a command similar to this one:

Get-CsUser –LdapFilter "ObjectClass=contact"

That's going to return just the contacts who have been assigned a SIP address.

Now you can see why we got so excited.

Interestingly enough, contacts don’t show up when you run Get-CsAdUser, regardless of whether or not those contacts have been assigned a SIP address. That’s because Get-CsAdUser doesn’t return information about contacts – period. As we just saw, however, Get-CsUser returns information about user accounts or about contacts, just as long as those objects have been assigned a SIP address.

In case you’re wondering (and we know that you are wondering), InetOrgPerson objects are retrieved by both Get-CsUser and Get-CsAdUser; Get-CsAdUser always displays information about InetOrg persons, while Get-CsUser displays information only if those InetOrg persons have been assigned a SIP address. Having discovered that we can return InetOrg persons, we then got a little greedy and tried to assign a SIP address to a computer. We could assign the SIP address; however, neither Get-CsAdUser nor Get-CsUser will return information about computers that have been assigned a SIP address.

Which is probably just as well. That might have been too much excitement.

Incidentally, this command returns information about both contacts and InetOrg persons who have been assigned SIP addresses. Would you ever need to run a command like that? Beats us. But if ever you do, well, here you go:

Get-CsUser –LdapFilter "|(ObjectClass=InetOrgPerson)(ObjectClass=contact)"

As you can see, here at Microsoft the fun just never ends.

This question is one of many asked during a session on managing Lync Server 2010 with Windows PowerShell at the TechReady 11 conference. For more questions and answers asked during that session, take a look at the Questions and Answers from TechReady 11 .