AddBinderyObjectToSet
Adds a bindery object to a property of type Set (For cross-platform functionality, see Developing NLMs with Cross-Platform Functions ( NDK: NLM Development Concepts, Tools, and Functions) and call NWAddObjectToSet)
#include <\nlm\nit\nwbindry.h>
int AddBinderyObjectToSet (
char *objectName,
WORD objectType,
char *propertyName,
char *memberName,
WORD memberType);
The objectName, objectType, and propertyName parameters must uniquely identify a bindery object’s property. These parameters must not contain wildcard characters. The property must be of type Set. The objectName can be from 1 to 48 characters long, including the NULL terminator. The propertyName can be from 1 to 16 characters long, including the NULL terminator. Only printable characters can be used. Slashes, backslashes, colons, semicolons, commas, asterisks, and question marks are prohibited.
The memberName and memberType parameters must uniquely identify the bindery object to be added and must not contain wildcard characters.
This function searches consecutive segments of the property’s value for an open slot where it can record the unique bindery object ID of the new member. The new member is inserted into the first available slot. If an open slot is not found, a new segment is created and the new member’s unique bindery object ID is written to the first slot in the segment. The rest of the segment is filled with zeros.
This function requires write access to the property.
For example, to add user BILL’s object ID to group STAFF’s GROUP_MEMBERS Set property, a programmer passes BILL’s object type (OT_USER) and object name (BILL) to the server with a call to AddBinderyObjectToSet. The server uses BILL’s object type and object name to locate BILL’s object ID. The server then searches all value segments associated with STAFF’s GROUP_MEMBERS Set property until it finds an available slot. Finally, it inserts BILL’s object ID number into the empty slot.
#include <stdio.h>
#include <\nlm\nit\nwbindry.h>
main()
{
int completionCode;
char objectName[48], propertyName[16], memberName[48];
WORD objectType, memberType;
/* Fill in the name of the object that is being added to */
strcpy (objectName, "STAFF");
/* Fill in the type of object that is being added to */
objectType = OT_GROUP;
/* Fill in the property name that is being added to */
strcpy (propertyName, "GROUP_MEMBERS");
/* Fill in the member name to be added */
strcpy (memberName, "BILL");
/* Fill in the member type to be added */
memberType = OT_USER;
completionCode = AddBinderyObjectToSet (objectName, objectType,
propertyName, memberName, memberType);
printf ("\n\n\n");
if (completionCode)
switch (completionCode)
{
case 150:
printf ("SERVER OUT OF MEMORY\n");
break;
case 233:
printf ("MEMBER ALREADY EXISTS\n");
break;
case 235:
printf ("NOT GROUP PROPERTY\n");
break;
case 240:
printf ("WILDCARD NOT ALLOWED\n");
break;
case 248:
printf ("NO PROPERTY WRITE PRIVILEGE\n");
break;
case 251:
printf ("NO SUCH PROPERTY\n");
break;
case 252:
printf ("NO SUCH OBJECT\n");
break;
case 254:
printf ("SERVER BINDERY LOCKED\n");
break;
case 255:
printf ("BINDERY FAILURE\n");
break;
case default:
printf ("completionCode = %d\n", completionCode);
break;
}
else
printf (" SUCCESSFULLY added member %s\n", memberName);
}