func (u *UserInfoLDAPSource) CreateGroup(groupinfo userinfo.GroupInfo) error {
	conn, err := u.getTargetLDAPConnection()
	if err != nil {
		log.Println(err)
		return err
	}
	defer conn.Close()

	entry := u.createGroupDN(groupinfo.Groupname)
	gidnum, err := u.getMaximumGIDNumber(conn, u.GroupSearchBaseDNs)
	if err != nil {
		log.Println(err)
		return err
	}

	var managerAttributeValue string
	switch strings.ToLower(u.GroupManageAttribute) {
	case "owner":
		if groupinfo.Description == "self-managed" {
			managerAttributeValue = entry
			break
		}
		managerDN, err := u.getGroupDN(conn, groupinfo.Description)
		if err != nil {
			log.Println(err)
			return err
		}
		managerAttributeValue = managerDN
	default:
		managerAttributeValue = groupinfo.Description
	}

	if len(groupinfo.Member) == 0 {
		for _, memberUid := range groupinfo.MemberUid {
			groupinfo.Member = append(groupinfo.Member, u.createUserDN(memberUid))
		}
	}
	log.Printf("groupinfo=%+v", groupinfo)

	group := ldap.NewAddRequest(entry)
	group.Attribute("objectClass", []string{"posixGroup", "top", "groupOfNames"})
	group.Attribute("cn", []string{groupinfo.Groupname})
	group.Attribute(u.GroupManageAttribute, []string{managerAttributeValue})
	if len(groupinfo.MemberUid) > 0 {
		group.Attribute("member", groupinfo.Member)
		group.Attribute("memberUid", groupinfo.MemberUid)
	}
	group.Attribute("gidNumber", []string{gidnum})
	err = conn.Add(group)
	if err != nil {
		log.Println(err)
		return err
	}
	log.Printf("Created new group (%+v)?", groupinfo)

	//flush group caches
	u.flushGroupCaches()

	return nil
}
//Creating a Group --required
Creating a Group --required
// Creating a Group -- required
func (u *UserInfoLDAPSource) CreateGroup(groupinfo userinfo.GroupInfo) error {
	conn, err := u.getTargetLDAPConnection()
	if err != nil {
		log.Println(err)
		return err
	}
	defer conn.Close()
	entry := u.createGroupDN(groupinfo.Groupname)
	gidnum, err := u.getMaximumGIDNumber(conn, u.GroupSearchBaseDNs)
	if err != nil {
		log.Println(err)
		return err
	}
	var managerAttributeValue string
	switch strings.ToLower(u.GroupManageAttribute) {
	case "owner":
		if groupinfo.Description == "self-managed" {
			managerAttributeValue = entry
			break
		}
		managerDN, err := u.getGroupDN(conn, groupinfo.Description)
		if err != nil {
			log.Println(err)
			return err
		}
		managerAttributeValue = managerDN
	default:
		managerAttributeValue = groupinfo.Description
	}
	if len(groupinfo.Member) == 0 {
		for _, memberUid := range groupinfo.MemberUid {
			groupinfo.Member = append(groupinfo.Member, u.createUserDN(memberUid))
		}
	}
	log.Printf("groupinfo=%+v", groupinfo)
	group := ldap.NewAddRequest(entry)
	group.Attribute("objectClass", []string{"posixGroup", "top", "groupOfNames"})
	group.Attribute("cn", []string{groupinfo.Groupname})
	group.Attribute(u.GroupManageAttribute, []string{managerAttributeValue})
	if len(groupinfo.MemberUid) > 0 {
		group.Attribute("member", groupinfo.Member)
		group.Attribute("memberUid", groupinfo.MemberUid)
	}
	group.Attribute("gidNumber", []string{gidnum})
	err = conn.Add(group)
	if err != nil {
		log.Println(err)
		return err
	}
	log.Printf("Created new group (%+v)?", groupinfo)
	u.flushGroupCaches()
	return nil
}
func ( u * UserInfoLDAPSource ) CreateGroup ( groupinfo userinfo . GroupInfo ) error { conn , err := u . getTargetLDAPConnection ( ) if err != nil { log . Println ( err ) return err } defer conn . Close ( ) entry := u . createGroupDN ( groupinfo . Groupname ) gidnum , err := u . getMaximumGIDNumber ( conn , u . GroupSearchBaseDNs ) if err != nil { log . Println ( err ) return err } var managerAttributeValue string switch strings . ToLower ( u . GroupManageAttribute ) { case " " : if groupinfo . Description == " " { managerAttributeValue = entry break } managerDN , err := u . getGroupDN ( conn , groupinfo . Description ) if err != nil { log . Println ( err ) return err } managerAttributeValue = managerDN default : managerAttributeValue = groupinfo . Description } if len ( groupinfo . Member ) == 0 { for _ , memberUid := range groupinfo . MemberUid { groupinfo . Member = append ( groupinfo . Member , u . createUserDN ( memberUid ) ) } } log . Printf ( " " , groupinfo ) group := ldap . NewAddRequest ( entry ) group . Attribute ( " " , [ ] string { " " , " " , " " } ) group . Attribute ( " " , [ ] string { groupinfo . Groupname } ) group . Attribute ( u . GroupManageAttribute , [ ] string { managerAttributeValue } ) if len ( groupinfo . MemberUid ) > 0 { group . Attribute ( " " , groupinfo . Member ) group . Attribute ( " " , groupinfo . MemberUid ) } group . Attribute ( " " , [ ] string { gidnum } ) err = conn . Add ( group ) if err != nil { log . Println ( err ) return err } log . Printf ( " " , groupinfo ) u . flushGroupCaches ( ) return nil }
Creating a Group --required
Creating a Group -- required
//flush group caches