Below is the example of using the SetMbSec operation to add a domain user connected from server. The request contains user name (the user must be in the domain) and necessary parameters. The response contains the updated list of repository users.
{
"SetMbSec" :
{
"tMbSec" :
{
"id" : "S1!M"
},
"tArg" :
{
"pattern" :
{
"users" : "Add",
"credsCache" : "Add"
},
"meta" :
{
"users" :
{
"its" :
{
"it" :
[
{
"k" : "0",
"id" : "FS\ASBADMIN",
"type" : "User",
"sid" :
{
"sid" : ""
},
"data" :
{
"isNT" : "true"
}
}
]
}
},
"credsCache" :
{
"its" :
{
"it" :
[
{
"realm" : "$SYSTEM",
"admin" : "true",
"creds" :
{
"user" :
{
"id" : "sa"
},
"pass" : "Qwerty1"
}
}
]
}
},
"currentDomainSubjectAddStates" :
{
"its" :
{
"it" :
[
{
"subjectType" : "User",
"state" : "98"
}
]
}
}
},
"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"
}
},
{
"k" : "532",
"id" : "GUEST",
"n" : "GUEST",
"vis" : "1",
"type" : "User",
"sid" :
{
"sid" : "PS-1-532",
"type" : "User"
}
},
{
"k" : "545",
"id" : "NEWADMIN",
"n" : "NewAdmin",
"vis" : "1",
"type" : "User",
"sid" :
{
"sid" : "PS-1-545",
"type" : "User"
}
},
{
"k" : "2147483646",
"id" : "FS\ASBADMIN",
"n" : "ASB Admin",
"vis" : "1",
"type" : "User",
"sid" :
{
"sid" : "S-1-5-21-2210245889-1953428358-4221806923-2817",
"type" : "User"
}
}
]
}
},
"bisearchEnable" : "Disable"
}
}
}
}
public static SetMbSecResult CreateDomainUser(string mb, string userName)
{
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.Add,
credsCache = ListOperation.Add
},
meta = new MbSecMd()
{
//Credentials, using which database server connection is executed.
//The specified user must have permissions to create users at DBMS level
credsCache = new UserCredsCache
{
its = new RealmUserCreds[]
{
new RealmUserCreds
{
realm = "$SYSTEM",
admin = true,
creds = new UserCreds
{
user = new UserId { id = "sa" },
pass = "Qwerty1"
}
}
}
},
users = new MbSubjects()
{
its = new MbSubject[1]
{
new MbSubject()
{
k = 0,
id = userName,
type = MbSubjectType.User,
sid = new SubjectSid() {sid = string.Empty},
data = new MbSubjectData()
{
isNT = true,
}
}
}
},
currentDomainSubjectAddStates = new MbSecDomainSubjectAddStateEntries()
{
its = new MbSecDomainSubjectAddStateEntry[1]
{
new MbSecDomainSubjectAddStateEntry()
{
state = 98, //MakeExternalOn + ManageDBGrantsOn + Keep
subjectType = MbSubjectType.User
}
}
}
},
//Options for updating users after operation execution
metaGet = new GetMbSecArg()
{
pattern = new MbSecMdPattern()
{
users = ListOperation.Get
}
}
},
//Repository moniker
tMbSec = new MbId() { id = mb }
};
//Create a domain user connected from server
var result = somClient.SetMbSec(setMbSec);
return result;
}
See also: