Below is the example of using the SetMbSec operation to change user parameters. The request contains a new user password and a group, to which the user is included. The response contains the updated list of repository users.
{
"SetMbSec" :
{
"tMbSec" :
{
"id" : "S1!M"
},
"tArg" :
{
"pattern" :
{
"users" : "Change",
"user" :
{
"data" : "true",
"memberOf" : "Set"
}
},
"meta" :
{
"users" :
{
"its" :
{
"it" :
[
{
"k" : "18446744073709551615",
"id" : "NewAdmin",
"vis" : "true",
"type" : "User",
"sid" :
{
"sid" : ""
},
"data" :
{
"memberOf" :
{
"its" :
{
"it" :
[
{
"k" : "2147483649",
"id" : "ADMINISTRATORS",
"n" : "ADMINISTRATORS",
"vis" : "true",
"type" : "Group",
"sid" :
{
"sid" : "PS-2-1",
"type" : "Group"
},
"data" :
{
"desc" : "Built-in administrator group",
"isNT" : "false",
"isExternal" : "true",
"isBuiltin" : "true",
"group" :
{
"members" :
{
"its" :
{
"it" :
[
{
"k" : "2147483649",
"id" : "ADMIN",
"vis" : "true",
"type" : "User",
"sid" :
{
"sid" : "PS-1-1",
"type" : "User"
}
}
]
}
},
"hasAccessToken" : "false"
}
}
}
]
}
},
"user" :
{
"credentials" :
{
"pass" : "q1"
},
"oldCredentials" :
{
"pass" : "NewAdmin"
}
}
}
}
]
}
}
},
"metaGet" :
{
"pattern" :
{
"users" : "Get"
}
}
}
}
}
{
"SetMbSecResult" :
{
"id" :
{
"id" : "S1!M"
},
"metaGet" :
{
"id" :
{
"id" : "S1!M"
},
"meta" :
{
"users" :
{
"its" :
{
"it" :
[
{
"k" : "2147483649",
"id" : "ADMIN",
"vis" : "1",
"type" : "User",
"sid" :
{
"sid" : "PS-1-1",
"type" : "User"
},
"data" :
{
"desc" : " ",
"isNT" : "0",
"isExternal" : "0",
"isBuiltin" : "1",
"user" :
{
"mustChangePasswordAtNextLogon" : "0",
"cannotChangePassword" : "0",
"lockedState" : "NotLocked",
"manageDBGrants" : "1",
"maxLogonSessions" : "0",
"lastLoginStamp" : "2018-10-24T11:31:20.847",
"hasAccessToRepository" : "1",
"isAdmin" : "1",
"isIsa" : "0",
"isRoled" : "0",
"changePassStamp" : "2018-10-24T06:31:31.000",
"autoRun" : "",
"temporaryAge" : "0",
"eternalPass" : "0",
"certificate" : ""
}
}
},
{
"k" : "532",
"id" : "GUEST",
"n" : "GUEST",
"vis" : "1",
"type" : "User",
"sid" :
{
"sid" : "PS-1-532",
"type" : "User"
},
"data" :
{
"isNT" : "0",
"isExternal" : "0",
"isBuiltin" : "0",
"user" :
{
"mustChangePasswordAtNextLogon" : "0",
"cannotChangePassword" : "0",
"lockedState" : "NotLocked",
"manageDBGrants" : "1",
"maxLogonSessions" : "0",
"lastLoginStamp" : "1899-12-30T00:00:00.000",
"hasAccessToRepository" : "1",
"isAdmin" : "0",
"isIsa" : "0",
"isRoled" : "0",
"changePassStamp" : "2018-10-22T10:30:33.000",
"autoRun" : "",
"temporaryAge" : "0",
"eternalPass" : "0",
"certificate" : ""
}
}
},
{
"k" : "545",
"id" : "NEWADMIN",
"n" : "NewAdmin",
"vis" : "1",
"type" : "User",
"sid" :
{
"sid" : "PS-1-545",
"type" : "User"
},
"data" :
{
"isNT" : "0",
"isExternal" : "0",
"isBuiltin" : "0",
"user" :
{
"mustChangePasswordAtNextLogon" : "0",
"cannotChangePassword" : "0",
"lockedState" : "NotLocked",
"manageDBGrants" : "1",
"maxLogonSessions" : "0",
"lastLoginStamp" : "1899-12-30T00:00:00.000",
"hasAccessToRepository" : "1",
"isAdmin" : "0",
"isIsa" : "0",
"isRoled" : "0",
"changePassStamp" : "2018-10-24T06:31:30.000",
"autoRun" : "",
"temporaryAge" : "0",
"eternalPass" : "0",
"certificate" : ""
}
}
}
]
}
},
"bisearchEnable" : "Disable"
}
}
}
}
public static SetMbSecResult ChangeUser(string mb, string userName, string oldPassword, string newPassword, MbSubject group)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var setMbSec = new SetMbSec()
{
tArg = new SetMbSecArg()
{
//Operation execution pattern
pattern = new MbSecMdPattern()
{
users = ListOperation.Change,
user = new MbSubjectPattern()
{
data = true,
memberOf = ListOperation.Set
}
},
meta = new MbSecMd()
{
users = new MbSubjects()
{
its = new MbSubject[1]
{
new MbSubject()
{
k = ulong.MaxValue,
id = userName,
vis = true,
type = MbSubjectType.User,
sid = new SubjectSid() {sid = string.Empty},
data = new MbSubjectData()
{
user = new MbUserData()
{
//Old password
oldCredentials = new UserCreds() {pass = oldPassword},
//New password
credentials = new UserCreds() {pass = newPassword}
},
//The group, to which the user is included
memberOf = new MbSubjects()
{
its = new MbSubject[1]
{
group
}
}
}
}
}
}
},
//Parameters for updating users list after operation execution
metaGet = new GetMbSecArg()
{
pattern = new MbSecMdPattern()
{
users = ListOperation.Get
}
}
},
//Repository moniker
tMbSec = new MbId() { id = mb }
};
//Change user parameters
var result = somClient.SetMbSec(setMbSec);
return result;
}
See also: