func (u *UserInfoLDAPSource) GetEmailofusersingroup(groupname string) ([]string, error) {
	conn, err := u.getTargetLDAPConnection()
	if err != nil {
		log.Println(err)
		return nil, err
	}
	defer conn.Close()

	groupUsers, _, err := u.getGroupUsersInternal(conn, groupname)
	if err != nil {
		log.Println(err)
		return nil, err
	}

	var userEmail []string
	log.Printf("GetEmailofusersingroup:%s, %+v", groupname, groupUsers)
	for _, entry := range groupUsers {
		value, err := u.getInfoofUserInternal(conn, entry, []string{"mail"})
		if err != nil {
			log.Println(err)
			if err == userinfo.UserDoesNotHaveEmail {
				continue
			}
			return nil, err
		}
		mail, ok := value["mail"]
		if !ok {
			log.Println("error get user email")
			return nil, errors.New("error get user email")
		}
		userEmail = append(userEmail, mail[0])

	}
	return userEmail, nil
}
//get email of all users in the given group
get email of all users in the given group
// get email of all users in the given group
func (u *UserInfoLDAPSource) GetEmailofusersingroup(groupname string) ([]string, error) {
	conn, err := u.getTargetLDAPConnection()
	if err != nil {
		log.Println(err)
		return nil, err
	}
	defer conn.Close()
	groupUsers, _, err := u.getGroupUsersInternal(conn, groupname)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	var userEmail []string
	log.Printf("GetEmailofusersingroup:%s, %+v", groupname, groupUsers)
	for _, entry := range groupUsers {
		value, err := u.getInfoofUserInternal(conn, entry, []string{"mail"})
		if err != nil {
			log.Println(err)
			if err == userinfo.UserDoesNotHaveEmail {
				continue
			}
			return nil, err
		}
		mail, ok := value["mail"]
		if !ok {
			log.Println("error get user email")
			return nil, errors.New("error get user email")
		}
		userEmail = append(userEmail, mail[0])
	}
	return userEmail, nil
}
func ( u * UserInfoLDAPSource ) GetEmailofusersingroup ( groupname string ) ( [ ] string , error ) { conn , err := u . getTargetLDAPConnection ( ) if err != nil { log . Println ( err ) return nil , err } defer conn . Close ( ) groupUsers , _ , err := u . getGroupUsersInternal ( conn , groupname ) if err != nil { log . Println ( err ) return nil , err } var userEmail [ ] string log . Printf ( " " , groupname , groupUsers ) for _ , entry := range groupUsers { value , err := u . getInfoofUserInternal ( conn , entry , [ ] string { " " } ) if err != nil { log . Println ( err ) if err == userinfo . UserDoesNotHaveEmail { continue } return nil , err } mail , ok := value [ " " ] if ! ok { log . Println ( " " ) return nil , errors . New ( " " ) } userEmail = append ( userEmail , mail [ 0 ] ) } return userEmail , nil }
get email of all users in the given group
get email of all users in the given group