I'm trying to add Object Type Nodes and organize them for my project (set variables, method and other properties) but the server is giving me BadUserAccessDenied.
Adding nodes and variables to the Demo Server Object is working.
I have overriden the:
Code: Select all
protected override bool HasAccessToAddNode(RequestContext context, BrowseHandle parent, NodeId referenceTypeId, NodeId typeDefinitionId)
{
return true;
}
Code: Select all
NodeId parendNode = NodeId.Parse(request.ParentIdentifier);
NodeId referenceType = NodeId.Parse(request.ReferenceTypeIdentifier);
ExpandedNodeId nodeType = ExpandedNodeId.Parse(request.NodeTypeIdentifier);
AddNodesItem nodeToAdd = new AddNodesItem()
{
ParentNodeId = parendNode, // this is Object Type folder, or Base Object Type
RequestedNewNodeId = new NodeId(request.Name, parendNode.NamespaceIndex), // with a given name under the parentNode namespaceindex
ReferenceTypeId = referenceType, // reference type I'm setting to HierarchicalReferences
NodeClass = (NodeClass)request.NodeClass, // Node class is ObjectType
TypeDefinition = nodeType, // Unspecified
BrowseName = new QualifiedName(request.Name, 1)
};
switch (nodeToAdd.NodeClass)
{
case NodeClass.Object:
{
nodeToAdd.NodeAttributes = new ExtensionObject(new ObjectAttributes()
{
SpecifiedAttributes = (uint)(NodeAttributesMask.DisplayName),
DisplayName = request.DisplayName
});
break;
}
case NodeClass.Variable:
{
NodeId DataType = NodeId.Parse(request.DataTypeIdentifier);
TypeInfo info = new TypeInfo(DataType, null);
nodeToAdd.NodeAttributes = new ExtensionObject(new VariableAttributes()
{
SpecifiedAttributes = (uint)(NodeAttributesMask.DataType | NodeAttributesMask.ValueRank | NodeAttributesMask.DisplayName),
DisplayName = request.DisplayName,
DataType = DataType,
ValueRank = request.ValueRank,
AccessLevel = AccessLevels.CurrentReadOrWrite
});
break;
}
}
Also I can maybe try to do this on the server implementation and create my own model, but I would like to make an API as this is my goal and to allow for users to manage these through a client web app.
Regards,
Agon