Beispiel #1
0
        private static void modifyRoleAssignment(modelPortType modelPort, String userOid, bool isAdd, String[] roleOids)
        {
            ItemDeltaType assignmentDelta = new ItemDeltaType();

            if (isAdd)
            {
                assignmentDelta.modificationType = ModificationTypeType.add;
            }
            else
            {
                assignmentDelta.modificationType = ModificationTypeType.delete;
            }
            assignmentDelta.path = createItemPathType("assignment");
            List <object> assignments = new List <object>();

            foreach (String roleOid in roleOids)
            {
                assignments.Add(createRoleAssignment(roleOid));
            }
            assignmentDelta.value = assignments.ToArray();

            ObjectDeltaType objectDelta = new ObjectDeltaType();

            objectDelta.objectType = USER_TYPE;
            objectDelta.changeType = ChangeTypeType.modify;
            objectDelta.oid        = userOid;
            objectDelta.itemDelta  = new ItemDeltaType[] { assignmentDelta };

            executeChanges         request  = new executeChanges(new ObjectDeltaType[] { objectDelta }, null);
            executeChangesResponse response = modelPort.executeChanges(request);

            check(response);
        }
Beispiel #2
0
 /**
  * Retrieves OID created by model Web Service from the returned list of ObjectDeltaOperations.
  *
  * @param operationListType result of the model web service executeChanges call
  * @param originalDelta original request used to find corresponding ObjectDeltaOperationType instance. Must be of ADD type.
  * @return OID if found
  *
  * PRELIMINARY IMPLEMENTATION. Currently the first returned ADD delta with the same object type as original delta is returned.
  */
 public static string getOidFromDeltaOperationList(ObjectDeltaOperationType[] operations, ObjectDeltaType originalDelta)
 {
     if (originalDelta.changeType != ChangeTypeType.add)
     {
         throw new ArgumentException("Original delta is not of ADD type");
     }
     if (originalDelta.objectToAdd == null)
     {
         throw new ArgumentException("Original delta contains no object-to-be-added");
     }
     foreach (ObjectDeltaOperationType operationType in operations)
     {
         ObjectDeltaType objectDeltaType = operationType.objectDelta;
         if (objectDeltaType.changeType == ChangeTypeType.add &&
             objectDeltaType.objectToAdd != null)
         {
             ObjectType1 objectAdded = (ObjectType1)objectDeltaType.objectToAdd;
             if (objectAdded.GetType().Equals(originalDelta.objectToAdd.GetType()))
             {
                 return(objectAdded.oid);
             }
         }
     }
     return(null);
 }
Beispiel #3
0
        private static void deleteUser(modelPortType modelPort, String oid)
        {
            ObjectDeltaType objectDelta = new ObjectDeltaType();

            objectDelta.objectType = USER_TYPE;
            objectDelta.changeType = ChangeTypeType.delete;
            objectDelta.oid        = oid;

            executeChanges         request  = new executeChanges(new ObjectDeltaType[] { objectDelta }, null);
            executeChangesResponse response = modelPort.executeChanges(request);

            check(response);
        }
Beispiel #4
0
        private static String createUser(modelPortType modelPort, UserType userType)
        {
            ObjectDeltaType deltaType = new ObjectDeltaType();

            deltaType.objectType  = USER_TYPE;
            deltaType.changeType  = ChangeTypeType.add;
            deltaType.objectToAdd = userType;

            executeChanges         request  = new executeChanges(new ObjectDeltaType[] { deltaType }, null);
            executeChangesResponse response = modelPort.executeChanges(request);

            return(getOidFromDeltaOperationList(response.deltaOperationList, deltaType));
        }
Beispiel #5
0
        private static void changeUserGivenName(modelPortType modelPort, String oid, String newValue)
        {
            ItemDeltaType itemDelta = new ItemDeltaType();

            itemDelta.modificationType = ModificationTypeType.replace;
            itemDelta.path             = createItemPathType("givenName");
            itemDelta.value            = new object[] { createPolyStringType(newValue) };

            ObjectDeltaType objectDelta = new ObjectDeltaType();

            objectDelta.objectType = USER_TYPE;
            objectDelta.changeType = ChangeTypeType.modify;
            objectDelta.oid        = oid;
            objectDelta.itemDelta  = new ItemDeltaType[] { itemDelta };

            executeChanges         request  = new executeChanges(new ObjectDeltaType[] { objectDelta }, null);
            executeChangesResponse response = modelPort.executeChanges(request);

            check(response);
        }
Beispiel #6
0
        private static void changeUserPassword(modelPortType modelPort, String oid, String newPassword)
        {
            ItemDeltaType passwordDelta = new ItemDeltaType();

            passwordDelta.modificationType = ModificationTypeType.replace;
            passwordDelta.path             = createItemPathType("credentials/password/value");
            passwordDelta.value            = new object[] { createProtectedStringType(newPassword) };

            ObjectDeltaType deltaType = new ObjectDeltaType();

            deltaType.objectType = USER_TYPE;
            deltaType.changeType = ChangeTypeType.modify;
            deltaType.oid        = oid;
            deltaType.itemDelta  = new ItemDeltaType[] { passwordDelta };

            executeChanges         request  = new executeChanges(new ObjectDeltaType[] { deltaType }, null);
            executeChangesResponse response = modelPort.executeChanges(request);

            check(response);
        }
Beispiel #7
0
        private static void deleteUser(modelPortType modelPort, String oid)
        {
            ObjectDeltaType objectDelta = new ObjectDeltaType();
            objectDelta.objectType = USER_TYPE;
            objectDelta.changeType = ChangeTypeType.delete;
            objectDelta.oid = oid;

            executeChanges request = new executeChanges(new ObjectDeltaType[] { objectDelta }, null);
            executeChangesResponse response = modelPort.executeChanges(request);
            check(response);
        }
Beispiel #8
0
	    private static void modifyRoleAssignment(modelPortType modelPort, String userOid, bool isAdd, String[] roleOids) 
        {
		    ItemDeltaType assignmentDelta = new ItemDeltaType();
		    if (isAdd) 
            {
			    assignmentDelta.modificationType = ModificationTypeType.add;
		    } 
            else 
            {
			    assignmentDelta.modificationType = ModificationTypeType.delete;
		    }
            assignmentDelta.path = createItemPathType("assignment");
            List<object> assignments = new List<object>();
		    foreach (String roleOid in roleOids) 
            {
                assignments.Add(createRoleAssignment(roleOid));
		    }
            assignmentDelta.value = assignments.ToArray();

            ObjectDeltaType objectDelta = new ObjectDeltaType();
            objectDelta.objectType = USER_TYPE;
            objectDelta.changeType = ChangeTypeType.modify;
            objectDelta.oid = userOid;
            objectDelta.itemDelta = new ItemDeltaType[] { assignmentDelta };

            executeChanges request = new executeChanges(new ObjectDeltaType[] { objectDelta }, null);
            executeChangesResponse response = modelPort.executeChanges(request);
            check(response);
    	}
Beispiel #9
0
        private static void changeUserGivenName(modelPortType modelPort, String oid, String newValue) 
        {
   		    ItemDeltaType itemDelta = new ItemDeltaType();
		    itemDelta.modificationType = ModificationTypeType.replace;
		    itemDelta.path = createItemPathType("givenName");
            itemDelta.value = new object[] { createPolyStringType(newValue) };

            ObjectDeltaType objectDelta = new ObjectDeltaType();
            objectDelta.objectType = USER_TYPE;
            objectDelta.changeType = ChangeTypeType.modify;
            objectDelta.oid = oid;
            objectDelta.itemDelta = new ItemDeltaType[] { itemDelta };

            executeChanges request = new executeChanges(new ObjectDeltaType[] { objectDelta }, null);
            executeChangesResponse response = modelPort.executeChanges(request);
            check(response);
        }
Beispiel #10
0
	    private static void changeUserPassword(modelPortType modelPort, String oid, String newPassword) 
        {
		    ItemDeltaType passwordDelta = new ItemDeltaType();
		    passwordDelta.modificationType = ModificationTypeType.replace;
		    passwordDelta.path = createItemPathType("credentials/password/value");
            passwordDelta.value = new object[] { createProtectedStringType(newPassword) };

            ObjectDeltaType deltaType = new ObjectDeltaType();
            deltaType.objectType = USER_TYPE;
            deltaType.changeType = ChangeTypeType.modify;
            deltaType.oid = oid;
            deltaType.itemDelta = new ItemDeltaType[] { passwordDelta };

            executeChanges request = new executeChanges(new ObjectDeltaType[] { deltaType }, null);
            executeChangesResponse response = modelPort.executeChanges(request);
            check(response);
    	}
Beispiel #11
0
 /**
  * Retrieves OID created by model Web Service from the returned list of ObjectDeltaOperations.
  *
  * @param operationListType result of the model web service executeChanges call
  * @param originalDelta original request used to find corresponding ObjectDeltaOperationType instance. Must be of ADD type.
  * @return OID if found
  *
  * PRELIMINARY IMPLEMENTATION. Currently the first returned ADD delta with the same object type as original delta is returned.
  */
 public static string getOidFromDeltaOperationList(ObjectDeltaOperationType[] operations, ObjectDeltaType originalDelta) {
 
     if (originalDelta.changeType != ChangeTypeType.add) 
     {
         throw new ArgumentException("Original delta is not of ADD type");
     }
     if (originalDelta.objectToAdd == null) 
     {
         throw new ArgumentException("Original delta contains no object-to-be-added");
     }
     foreach (ObjectDeltaOperationType operationType in operations) 
     {
         ObjectDeltaType objectDeltaType = operationType.objectDelta;
         if (objectDeltaType.changeType == ChangeTypeType.add &&
             objectDeltaType.objectToAdd != null) 
         {
             ObjectType1 objectAdded = (ObjectType1) objectDeltaType.objectToAdd;
             if (objectAdded.GetType().Equals(originalDelta.objectToAdd.GetType())) 
             {
                 return objectAdded.oid;
             }
         }
     }
     return null;
 }
Beispiel #12
0
	    private static String createUser(modelPortType modelPort, UserType userType)
        {
            ObjectDeltaType deltaType = new ObjectDeltaType();
            deltaType.objectType = USER_TYPE;
            deltaType.changeType = ChangeTypeType.add;
            deltaType.objectToAdd = userType;

            executeChanges request = new executeChanges(new ObjectDeltaType[] { deltaType }, null);
            executeChangesResponse response = modelPort.executeChanges(request);

		    return getOidFromDeltaOperationList(response.deltaOperationList, deltaType);
	    }