0 Comments

 

I’ve written fair amount of routines to query Active Directory to find users. AD is great when you need to obtain certain user information stored in attributes. Most often you need a list of windows groups so that you can check permissions etc.,

But recently I was working on implementing a requirement, which was about collecting user information in UI, with name and address validation. And as I was reading through the documentation I could not help but to notice that it looked remarkably similar to SharePoint user control.

 

Sharepoint People

 

So, I began researching it and came across People.asmx, part of the SharePoint Services. And after modifications to this control from Assign Labs

jALPeoplePicker 1.0.0

I was able to produce similar functionality to what SharePoint has accept customized to given requirement.

 

So, if your organization has SharePoint Services deployed, and most do, you definitely have it.

The common address for the service is:

http://<Site>/_vti_bin/People.asmx

Two methods of interest are:
ResolvePrincipals

Resolves an e-mail address or other form of user identification (ID) into a PrincipalInfo object.
SearchPrincipals

Returns an array of PrincipalInfo objects from the SPUserCollection for the Web site. All instances have the principal logon name specified in searchText. Only the maxResults objects can be added to the array.

Here is an example on how request and response look like:

<s:Envelope>

<s:Body>

<SearchPrincipals>

<searchText>Name</searchText>

<maxResults>100</maxResults>

<principalType>All</principalType>

</SearchPrincipals>

</s:Body>

</s:Envelope>

 

<soap:Envelope>

<soap:Body>

<SearchPrincipalsResponse>

<SearchPrincipalsResult>

<PrincipalInfo>

<AccountName>DOMAIN\login</AccountName>

<UserInfoID>-1</UserInfoID>

<DisplayName>Last, First</DisplayName>

<Email/>

<Department/>

<Title/>

<IsResolved>true</IsResolved>

<PrincipalType>User</PrincipalType>

</PrincipalInfo>

<PrincipalInfo>

<AccountName>DOMAIN\login</AccountName>

<UserInfoID>-1</UserInfoID>

<DisplayName>Last, First</DisplayName>

<Email>email@email.com</Email>

<Department>DEPARTMENT</Department>

<Title>President</Title>

<IsResolved>true</IsResolved>

<PrincipalType>User</PrincipalType>

</PrincipalInfo>

</SearchPrincipalsResult>

</SearchPrincipalsResponse>

</soap:Body>

</soap:Envelope>

What makes it useful is that you can search by multiple types like login name or name or email address. You might need to perform some filtering on the results since based on how Authentication was configured in your organization the results might be coming back a little weird.

But other than that I thought the service was pretty cool, saved me bunch of time, since I did not have to do any of the matching via AD routines.