22.12.2012 Views

Front cover - IBM Redbooks

Front cover - IBM Redbooks

Front cover - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

int getUserNames (FilterContext* context,<br />

char *userName,<br />

char **pUserFullName,<br />

int *pUserFullNameLen,<br />

char **pUserShortName,<br />

int *pUserShortNameLen) {<br />

/*<br />

* Description: Lookup the user and return the user's full name and short name.<br />

*<br />

* Input: context context we'll use for allocating memory<br />

* userName the name of the user to lookup<br />

* Output: pUserFullName location of the user's full name<br />

* pUserFullNameLen location to store the length of fullname<br />

* pUserShortName location of the user's shortname<br />

* pUserShortNameLen location to store the length of shortname<br />

*<br />

* Return: -1 on error, 0 on success<br />

*/<br />

STATUS error = NOERROR;<br />

HANDLE hLookup = NULLHANDLE;<br />

DWORD Matches = 0;<br />

char *pLookup;<br />

char *pName = NULL;<br />

char *pMatch = NULL;<br />

int rc = -1;<br />

/* Initialize output */<br />

*pUserFullName = NULL;<br />

*pUserFullNameLen = 0;<br />

*pUserShortName = NULL;<br />

*pUserShortNameLen = 0;<br />

/* do the name lookup<br />

*/<br />

error = NAMELookup2(NULL, /* NULL means look locally */<br />

0, /* flags */<br />

1, /* number of namespaces */<br />

"$Users", /* namespace list */<br />

1, /* number of names to lookup */<br />

userName, /* list of names to lookup */<br />

2, /* number of items to return */<br />

"FullName\0ShortName", /* list of items to<br />

* return */<br />

&hLookup); /* place to receive handle of<br />

* return buffer */<br />

if (error || (NULLHANDLE == hLookup))<br />

Appendix B. A sample DSAPI program 649

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!