Active Directory get users in role - active-directory

I get the members of a AD group, but instead of the user name, im getting the display name.
How can i get the user name?

Look for sAMAccountName in the properties you get back.

Well, i think this might be impossible, as the only users related property is the "members".
So as a workaround i used the DirectoryService with the "member" property value to fetch the user again from the AD and get it's sAMAaccoundName.
I'll be happy to hear about another solution to save the call to the AD for each user except the first call.
Thanks

Related

How to get all Active Directory user details using Search Filter Syntax

How can I get all users properties like (email, address, phone and etc..)
using search filter syntax?
Can't find anything in the docs.
I tried this
(&(objectCategory=person)(objectClass=user)(cn=Erika Wynn))
but all I get is the dn details :
CN=Erika Wynn,CN=Users,DC=****,DC=local
I wish to get all user fields General (telephone, email..), Address (Street, City), Organization.
LDAP allows you to specify which attributes you want to receive. If you do not specify anything, Active Directory will return every attribute that has a value. So if it is not doing that in your case, then there must be some part of the code that has set the list of attributes to only the distinguishedName.
You will have to show your code for us to help you more. You can update your question to include your code.
I should of just provide a user name similar to AD login, as a filter and any attribute I needed to get.
I used this great article, to get all the different attributes that you can fetch from Active Directory.
https://www.manageengine.com/products/ad-manager/help/csv-import-management/active-directory-ldap-attributes.html
this is the query:
filter=(sAMAccountName=username) attributes=cn,department,company,streetAddress,L,st,co,mail

Drupal Replacement Pattern for Entity Reference

I have a Profile Type attached to a user. In there I have a Entity Reference Field of Program Manager. I have Live Events(content-type) that people can register for. I set up a Rule to Email the Program Manager every time someone registers.
My problem is I am trying to pull information from the Profile based on the the entity reference for the Program Manager.
I have the field printing out by using this pattern...
[registration:entity:field_program_manager]
However when I try to pull the first name, email of phone I can not get it to show up.
Does anyone have any ideas to share?
Many Thanks!
Okay so I was trying to solve for sending the email to the Author of the page but was having issues. So I created a new fields hoping it would be easier. In trying to solve for this I solved the original issue.
To print the Author of a node to an email through Rules actions us this.
[registration:entity:author]
So for first name it would be:
[registration:entity:author:profile-main:field_first_name]
Hope it helps someone else.
If you're using entityform instead of a node and referencing the default user info (not the 'Main Profile' profile type), then you want to use something like
[entityform:field-staff-entity-ref:field-work-email]
In this case, 'field-staff-entity-ref' is the entity reference field in the entityform and 'field-work-email' is the field in the user's account settings.

Drupal 7 views contextual filter restrict content based on current users role

I'd like to restrict access to a view based on the CURRENT users role. Not the author. For example, if a user has the authorized user role then they can see the content of the view. If a user is anonymous then they are shown the No Results Behavior of the view. I can't believe there is no way to do this. I know there is the Access settings, but I don't want the anonymous user given an access denied message.
One method I can think of:
Use hook_views_query_alter(). Check if the current user belongs to the set of roles you are interested in. If he doesn't, add a condition which is always false, such as 0 = 1. To see how to add such a condition in code, see the example on this page: http://api.drupal.org/api/views/views.api.php/function/hook_views_query_alter/7. The resulting view will not have any result on adding this condition.
Neerav Mehta.
Drupal Development

Visualforce: How to display user's account using the $User

I have a visualforce component which I use for displaying the user's name.
Currently I am doing it using the following:
!$User.FirstName} {!$User.LastName}
Is there any way I can display the User's Account as well using this without writing SOQL.
I would not like to create a controller just to display the user's account and am hoping there is a simpler and easier way using just Visual force.
I did try !$User.Contact.Account}
But it gave me an error.
Thanks.
Here are two things you may want to try:
Reference the Account Name from the $User Visualforce global variable.
{!$User.Contact.Account.Name}
If that doesn't work, create a new formula field on the User object named Contact Account Name with this formula: Contact.Account.Name. Once you have created that formula field, you should be able to reference it in Visualforce using: {!$User.Contact_Account_Name__c}.

Get a Google App Engine user by their user_id

In GAE, can you look up a User with the User object's user_id?
In other words, is there something equivalent to:
from google.appengine.api.users import User
user = User.get_by_id(user_id)
I don't think so.
... they certainly wouldn't just give you access to every holder of a google account!
The idea is that you store user ids as properties in your datastore, once they've logged in to your app.
There is a property type called UserProperty
http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html
So, you can query your list of users from your own datastore definition.
hth
This seems to be the only post on the internet regarding this and since I was looking for a solution, I thought I'd post what I found here.
What amir75 said about using the UserProperty is fine for storing the User object itself returned by the google.appengine.users module.
But if you need to lookup a User by the user_id field instead of the default email field, usually something like user = User(email = 'validmail#gmailorgapps.com')
You can use this to query by user_id. user = User(_user_id = 'validuserid') The valid user_id is something that you got earlier from calling user.user_id()
I'm not sure what amir75 is referring to about having access to all google accounts since the User object returned will only have the email address and nickname, and that too only if the user authorizes the application to access that information.
My use case for this is I want people to sign up on the site, but they need an administrator to confirm them for using the site. The form used by the administrator for confirming the users can use email id as the field to identify the checkbox for confirming the user, but given that it might change, the user_id seems to be a safer field to use.

Resources