I am trying to retrieve the "Members)" information from Exchange "Role assignments" (eg. Compliance Management, Discovery Management, ExchangeServiceAdmins_xx, etc) using the following code but am not able to find them. It is only able to list the "Assigned Roles" in the Azure Active Directory.
Any idea what I have doing wrong here?
DirectoryObjectCollectionWithReferencesPage roles = gGraphClient.users(username).memberOf().buildRequest().get();
DirectoryObject r;
DirectoryRole role;
Group g;
if (roles == null)
{
throw new Exception("Bye");
}
List<DirectoryObject> currentPageGroup = roles.getCurrentPage();
Iterator itr = currentPageGroup.iterator();
while (itr.hasNext())
{
r = (DirectoryObject) itr.next();
if (r.oDataType.endsWith("group"))
{
g = (Group) r;
System.out.println(g.displayName);
}
else
{
role = (DirectoryRole) r;
System.out.println(role.displayName);
}
}
Related
I have access to TFS users. I can get them into list but need to remove some of them from all the groups in our TFS. I've done so many researchers so far. Simply, I need to remove user from TFS groups.
I am open to any suggestions. Even for the crazy ones!
I've tried programmatical stuff. Don't have any clue.
After so many tries, finally got somewhere. My final code:
bool isError = false;
TeamFoundationIdentity memberId = ims.ReadIdentity(IdentitySearchFactor.DisplayName, id.DisplayName, MembershipQuery.Expanded, ReadIdentityOptions.None);
IIdentityManagementService2 ims2 = tcs.GetService<IIdentityManagementService2>();
string group = "Confidential Group;
TeamFoundationIdentity groupId = ims2.ReadIdentity(group);
if (groupId == null)
{
isError = true;
}
if (memberId == null)
{
isError = true;
}
if (!isError)
{
ims2.RemoveMemberFromApplicationGroup(groupId.Descriptor, memberId.Descriptor);
}
The error:
'TF50621: The Team Foundation group that you wish to manage is not owned by service host TEAM FOUNDATION, it is owned by . Please target your request at the correct host.'**
Check out the Azure Boards Team Tools.
It does most of what you need already:
message = string.Empty;
bool ret = true;
TeamFoundationTeam t = this.teamService.ReadTeam(this.projectInfo.Uri, team, null);
TeamFoundationIdentity i = this.identityManagementService.ReadIdentity(IdentitySearchFactor.AccountName, user, MembershipQuery.Direct, ReadIdentityOptions.None);
if (t == null)
{
message = "Team [" + team + "] not found";
ret = false;
}
if (i == null)
{
message = "User [" + user + "] not found";
ret = false;
}
if (ret)
{
this.identityManagementService.RemoveMemberFromApplicationGroup( t.Identity.Descriptor, i.Descriptor);
message = "User removed ";
}
return ret;
This function removes a user from a Team. A Team is a special kind of group, the function is easy to adapt to retrieve a Group to delete the user from though:
Replace
TeamFoundationTeam t = this.teamService.ReadTeam(this.projectInfo.Uri, team, null);
With:
string group = ...
var t = this.identityManagementService.ReadIdentity(group);
Or use the REST API :
DELETE https://vsaex.dev.azure.com/{organization}/_apis/GroupEntitlements/{groupId}/members/{memberId}?api-version=7.1-preview.1
protected void Button1_Click(object sender, EventArgs e)
{
//Incident Service
IncidentService.ServiceNowSoapClient soapClient = new IncidentService.ServiceNowSoapClient();
soapClient.ClientCredentials.UserName.UserName = "username"; // username have SOAP role in SNow.
soapClient.ClientCredentials.UserName.Password = "Password1";
IncidentService.getRecords _getRecords = new IncidentService.getRecords();
IncidentService.getRecordsResponseGetRecordsResult[] getRecordsResponses = soapClient.getRecords(_getRecords);
_getRecords.active = true;
// Note: Please enable SOAP/REST services in your SNow dev instance table(s), Also,
// Go to system web services --> properties -> enable the 3rd option from the bottom.(This property sets the elementFormDefault attribute of the embedded XML schema to the value of unqualified)
//ServiceNowSoapClient client = new ServiceNowSoapClient();
//client.ClientCredentials.UserName.UserName = "username"; // username have SOAP role in SNow.
//client.ClientCredentials.UserName.Password = "Password1";
//insert newRecord = new insert();
//insertResponse insertResponse = new insertResponse();
//newRecord.first_name = "Jackson";
//newRecord.last_name = "Chris";
//newRecord.phone_number = "911-911-9999";
//newRecord.number = "CUS3048232";
try
{
//insertResponse = client.insert(newRecord);
//TextBox1.Text = insertResponse.sys_id;
getRecordsResponses = soapClient.getRecords(_getRecords);
for (int i = 0; i < getRecordsResponses.Length; i++)
{
TextBox2.Text = getRecordsResponses[i].short_description;
TextBox3.Text = getRecordsResponses[i].category;
}
}
catch (Exception ex)
{
TextBox1.Text = ex.Message;
}
//finally { client.Close(); }
}
How do you leverage ServiceNow data that reside in enterprise servicenow(CMDB,ITIL,various enterprise dbs, new dbs) dev,prod instances
to create End to End automated applications with C#, dotnetcore.
our goal is to Automate applications end to end with ServiceNow, dotnetcore, C#, docker containers, Ansible, Automic.
I know you probably don't need, maybe someone looking for the same finds this question.
I developed an library just for that.
https://emersonbottero.github.io/ServiceNow.Core/
When an user creates a meeting directly in the calendar of a conference room, the organizer field is set as the room's name(Not has the user who has created the meeting).
Is it possible to get the name of the user who has created the meeting using EWS 2010?.
If you check the Sender Extended properties that should show the creators name (while send on behalf would be the Mailbox name) e.g.
Mailbox MeetingRoom = new Mailbox("room#domain.com");
FindItemsResults<Appointment> appts = service.FindAppointments(new FolderId(WellKnownFolderName.Calendar,MeetingRoom),new CalendarView(DateTime.Now,DateTime.Now.AddMonths(1),1000));
ExtendedPropertyDefinition PR_SENDER_EMAIL_ADDRESS_W = new ExtendedPropertyDefinition(0x0C1F,MapiPropertyType.String);
ExtendedPropertyDefinition PR_SENDER_ADDRTYPE_W = new ExtendedPropertyDefinition(0x0C1E,MapiPropertyType.String);
PropertySet psProps = new PropertySet();
psProps.Add(PR_SENDER_ADDRTYPE_W);
psProps.Add(PR_SENDER_EMAIL_ADDRESS_W);
if(appts.Items.Count > 0){
service.LoadPropertiesForItems(from Item item in appts select item,psProps);
foreach(Appointment apt in appts){
Object SenderAddressType = null;
Object SenderAddress = null;
if(apt.TryGetProperty(PR_SENDER_ADDRTYPE_W,out SenderAddressType)){
if(apt.TryGetProperty(PR_SENDER_EMAIL_ADDRESS_W,out SenderAddress)){
if(SenderAddressType.ToString() == "EX")
{
NameResolutionCollection nccol = service.ResolveName(SenderAddress.ToString(),ResolveNameSearchLocation.DirectoryOnly,true);
if(nccol.Count == 1){
Console.WriteLine(nccol[0].Mailbox.Address);
}
}
else
{
Console.WriteLine(SenderAddress);
}
}
}
}
}
I would like to know whether the retrieved sid ("currentSid") from a permission in the acl_entry table is that of a principal or authority.
for (int j = 0; j < acl.getEntries().size(); j++) {
String currentPermissionPattern = acl.getEntries().get(j).getPermission().getPattern();
String currentSid = acl.getEntries().get(j).getSid().toString();
}
I am currently storing currentSid as string. Lets say I stored it as Sid, how can I know if this Sid belongs to a user or a role.
You could do this:
if (acl.getEntries().get(j).getSid() instanceof GrantedAuthoritySid) {
GrantedAuthoritySid sid = (GrantedAuthoritySid) acl.getEntries().get(j).getSid();
// it's role
} else {
PrincipalSid sid = (PrincipalSid) acl.getEntries().get(j).getSid();
// it's user
}
I want to retrieve all clientID from my MCC account. I'm using this code
AdWordsUser user = new AdWordsUser(adwordsPropertyService.getEmail(), adwordsPropertyService.getPassword(),
null, adwordsPropertyService.getUseragent(), adwordsPropertyService.getDeveloperToken(),
adwordsPropertyService.getUseSandbox());
InfoServiceInterface infoService = user.getService(AdWordsService.V201109.INFO_SERVICE);
InfoSelector selector = new InfoSelector();
selector.setApiUsageType(ApiUsageType.UNIT_COUNT_FOR_CLIENTS);
String today = new SimpleDateFormat("yyyyMMdd").format(new Date());
selector.setDateRange(new DateRange(today, today));
selector.setIncludeSubAccounts(true);
ApiUsageInfo apiUsageInfo = infoService.get(selector);
for (ApiUsageRecord record : apiUsageInfo.getApiUsageRecords()) {
......
But apiUsageInfo.getApiUsageRecords return my only some clientId.
Have you any suggests?
My Answer will be helpful for PHP Developers
I am using v201502(php), You will get all account details from ManagedCustomerService api. Please refer the following URL https://developers.google.com/adwords/api/docs/reference/v201502/ManagedCustomerService
This is the sample code i used,
function DisplayAccountTree($account, $link, $accounts, $links, $depth) {
print str_repeat('-', $depth * 2);
printf("%s, %s\n", $account->customerId, $account->name);
if (array_key_exists($account->customerId, $links)) {
foreach ($links[$account->customerId] as $childLink) {
$childAccount = $accounts[$childLink->clientCustomerId];
DisplayAccountTree($childAccount, $childLink, $accounts, $links,
$depth +1);
}
}
}
function GetAccountHierarchyExample(AdWordsUser $user) {
// Get the service, which loads the required classes.
$user->SetClientCustomerId('xxx-xxx-xxxx');
$managedCustomerService =
$user->GetService('ManagedCustomerService');
// Create selector.
$selector = new Selector();
// Specify the fields to retrieve.
$selector->fields = array('CustomerId', 'Name');
// Make the get request.
$graph = $managedCustomerService->get($selector);
// Display serviced account graph.
if (isset($graph->entries)) {
// Create map from customerId to parent and child links.
$childLinks = array();
$parentLinks = array();
if (isset($graph->links)) {
foreach ($graph->links as $link) {
$childLinks[$link->managerCustomerId][] = $link;
$parentLinks[$link->clientCustomerId][] = $link;
}
}
// Create map from customerID to account, and find root account.
$accounts = array();
$rootAccount = NULL;
foreach ($graph->entries as $account) {
$accounts[$account->customerId] = $account;
if (!array_key_exists($account->customerId, $parentLinks)) {
$rootAccount = $account;
}
}
// The root account may not be returned in the sandbox.
if (!isset($rootAccount)) {
$rootAccount = new Account();
$rootAccount->customerId = 0;
}
// Display account tree.
print "(Customer Id, Account Name)\n";
DisplayAccountTree($rootAccount, NULL, $accounts, $childLinks, 0);
} else {
print "No serviced accounts were found.\n";
}
}
GetAccountHierarchyExample($user);
SetClientCustomerId will be the parent ID of your all accounts, It will be appeared near the Sign Out button of you google AdWords account, Please see the attached image
I hope this answer will be helpful, Please add your comments below if you want any further help
If you need just the list of clientCustomerIds, try ServicedAccountService.
Here is a code example that shows how this may be done.
Next time, you might also want to consider asking the question on the official forum for AdWords API: https://groups.google.com/forum/?fromgroups#!forum/adwords-api