Get all contacts from exchange server - exchange-server

I want to get all users from Exchange server, I don't want to get user's contacts. In fact, I want to get all AD users as Active Directory which we can't connect to.
mExchangeService.ImpersonatedUserId = new ImpersonatedUserId
{
Id = "jack#aa.com",
IdType = ConnectingIdType.SmtpAddress
};
var contacts = _mExchangeService.FindItems(new FolderId(WellKnownFolderName.Contacts),new ItemView(1000));
I can above code to get user's contact, but that's not I want, I want use a service account to get all Exchange web service users.

You can sort of use EWS for retrieving your directory users using ExhangeService.ResolveName. The problem is that EWS will return no more than 100 users and there is no way to change it or to do any paging. So if you are in a larger company you can't really do it using EWS.
The code:
var nameResolutionCollection = service.ResolveName("SMTP:",
ResolveNameSearchLocation.DirectoryOnly, true);
foreach (var c in nameResolutionCollection)
{
Console.WriteLine(c.Mailbox.Address);
}
Console.WriteLine(nameResolutionCollection.Count()); // Maximum 100 users.

Related

One to one chat in socket io

Need help with socketio one to one chat.
I have read tons of example stating to create a room for private chat.
The example one I always get will be something like this :
io.on('connection', socket => {
//Get the chatID of the user and join in a room of the same chatID
chatID = socket.handshake.query.chatID
socket.join(chatID)
//Leave the room if the user closes the socket
socket.on('disconnect', () => {
socket.leave(chatID)
})
//Send message to only a particular user
socket.on('send_message', message => {
receiverChatID = message.receiverChatID
senderChatID = message.senderChatID
content = message.content
//Send message to only that particular room
socket.in(receiverChatID).emit('receive_message', {
'content': content,
'senderChatID': senderChatID,
'receiverChatID':receiverChatID,
})
})
});
But I can't get my head around: as in this example for the room "receiverChatID", all user who are currently sending message to the same receiver [say user2] will receive a broadcast of the messages other user are sending.
For example user 1 and user 2 are having private chat conversation. The chat room id is "user2".
Now user3 sends message to user 2, again the room name will be "user2" and hence when a broadcast will be done, both user 3 and user 1 will receive messages , even though they should be private individually.
One way will be to create a unique chat-room-id between two users, and maintain in it some data store.If that is the way to do it, then how to create unique chat room id, specifically, when user join and leave and re-join save room.
And query this unqique room for two users, whenever they join in ?
Say I create a map : {roomid1: MD5["user1","user2"]}.
Now how do you decide the order of user1 and user 2 [alphabetical I guess], so for two pairs of users one unique room id is created ?
How do you solve this problems for one to one chat ?

Discover Google calendar created with service account

I created new Google calendar with API v3 in c# with Service account. I also set ACL rule:
var permission = new AclRule()
{
Scope = new AclRule.ScopeData() { Type = "domain", Value = "mydomain.com" },
Role = "reader",
};
Problem is how can users of domain "nicely" add this calendar to "Other calendars" in calendar.google.com site?
They can add it if they enter calendar id, which is not user friendly, since id is some random string:
4b123456789glvpvasaaaaaaaar4#group.calendar.google.com
. I though I could search by calendar summary. But this is not the case. Only entering complete calendarId adds it to calendar list.

Google Groups API - getUsers() You do not have permission to view the member list for the group:

Cheers Everyone!
I have a Google script which checks if e-mail addresses are members of a group or not by using getUsers() function.
So far:
I have activated "Admin SDK Directory Service"
I have admin authority
For most of the groups it does it's magic, however I get authorization error in case of some groups.
Error message from Log:
"You do not have permission to view the member list for the group: foo#bar"
Any idea what might be the problem?
Anything is very much appreciated.
Thank you!
The problem is that the GroupsApp service uses the permissions of the GROUP to determine whether or not you can view the members list. The default setting for groups is to restrict this access to owners and managers of the group. So you have two options:
1) Make yourself an owner or manager of the group OR
2) Use the Admin SDK to check for group membership. The Admin SDK allows any super admin to view the list of users in a group. To find out whether a user is a member of a group, you would need to retrieve the group, then iterate through the members list and then compare each member against the user you are looking for:
function isMember(groupKey,userKey){
//groupKey: testGroup#yourdomain.com
//userKey: userEmail#yourdomain.com
var memberList = [];
//Get the members list from the group
var response = AdminDirectory.Members.list(groupKey);
memberList = memberList.concat(response.members);
while (response.nextPageToken){
response = AdminDirectory.Members.list(groupKey,{pageToken: response.nextPageToken});
memberList = memberList.concat(response.members);
}
if (memberList.length > 1){
for (var x in memberList){
if (memberList[x].email == userKey){return true;}
}
}
}
More info Here

OData V4 AddObject SetLink odata.bind does not trasmit related entities

I've created a OData V4 Service described in the articles on the ASP.NET Homepage.
I basically have a table Events where I assign Guests to. I need additional information to this many to many relationship, so I have created a EventGuest table.
Inserting Events and inserting Guests via OData just works fine. It just doesn't want to work, as soon as I want to insert related entities.
This is my Controller-Code:
public async Task<IHttpActionResult> Post(EventGuest eventGuest)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
_db.EventGuest.AddOrUpdate(eventGuest);
await _db.SaveChangesAsync();
return Created(eventGuest);
}
And this is how I want to insert the relationship. For the Client Code I use the official T4 template.
var ev = container.Event.FirstOrDefault();
var guest = container.Guest.FirstOrDefault();
var evGuest = new EventGuest();
evGuest.Guid = Guid.NewGuid();
container.AddObject("EventGuest", evGuest);
container.SetLink(evGuest, "Event", ev);
container.SetLink(evGuest, "Guest", guest);
container.SaveChanges();
The request sent to the Server doesn't look too bad for me:
{"#odata.type":"#Entities.EventGuest","CreationTimestamp":"0001-01-01T00:00:00Z","Guid":"adf500e3-e3a1-4841-883e-2322ed863321","ID":0,"Event#odata.bind":"http://localhost/odata/Event(1)","Guest#odata.bind":"http://localhost/odata/Guest(1)"}
So the Server tries to use #odata.bind, but unfortunately in the POST-Method of the Controller the referenced entities "Guest" and "Event" are null.
Have you tried following the example at the MSDN Documentation? I noticed it always uses AddLink rather than SetLink, even in the SetLink documentation.
MSN Article is here: DataServiceContext.SetLink Method

Public image url from Google Gdata Contacts API

I'm trying to display related users through the Google GData Contacts API.
URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
Query q = new Query(feedUrl);
q.setMaxResults(max);
q.setUpdatedMin(q.getUpdatedMin());
ContactFeed feed = client.query(q, ContactFeed.class);
for(ContactEntry item : feed.getEntries()){
[...]
}
I know that there is a public image url for profiles on Google.
https://www.google.com/s2/photos/profile/{user_id}
https://plus.google.com/s2/photos/profile/{user_id}
https://profiles.google.com/s2/photos/profile/{user_id}
However, when I retrieve a user's contacts, there just doesn't seem to be a field available to reference that user_id.

Resources