Directory Services

AllocADsStr

The AllocADsStr function creates a deep copy of a specified string. To release the memory allocated by this function, use FreeADsStr.

LPWSTR AllocADsStr(
  LPWSTR pStr
);

Parameters

pStr
[in] The null-terminated Unicode string that must be allocated and stored.

Return Values

The function returns a non-NULL pointer to the successfully allocated memory for the string. It returns NULL if the operation failed.

Remarks

Use the function in the following code example to create strings used in ADSI.

#define LDAP 0
#define WINNT 1
LPWSTR namespace = NULL;
int prov=0;
. . .
if (prov == WINNT) {
	namespace = AllocADsStr(L"WinNT://");
}
else {
	namespace = AllocADsStr(L"LDAP://");
}
. . .
// When finished with namespace, free the string.
FreeADsStr(namespace);

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Adshlp.h.
Library: Use ActiveDS.lib.

See Also

ADSI Functions, FreeADsStr