mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-16 13:27:37 -04:00
Until the LDAP backend is ready the existing CS3 code should keep working. This also adds the initial stubs for the upcoming LDAP Backend.
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package identity
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
|
|
cs3 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
|
msgraph "github.com/yaegashi/msgraph.go/beta"
|
|
)
|
|
|
|
type Backend interface {
|
|
GetUser(ctx context.Context, nameOrId string) (*msgraph.User, error)
|
|
GetUsers(ctx context.Context, queryParam url.Values) ([]*msgraph.User, error)
|
|
|
|
GetGroup(ctx context.Context, nameOrId string) (*msgraph.Group, error)
|
|
GetGroups(ctx context.Context, queryParam url.Values) ([]*msgraph.Group, error)
|
|
}
|
|
|
|
func CreateUserModelFromCS3(u *cs3.User) *msgraph.User {
|
|
if u.Id == nil {
|
|
u.Id = &cs3.UserId{}
|
|
}
|
|
return &msgraph.User{
|
|
DisplayName: &u.DisplayName,
|
|
Mail: &u.Mail,
|
|
// TODO u.Groups are those ids or group names?
|
|
OnPremisesSamAccountName: &u.Username,
|
|
DirectoryObject: msgraph.DirectoryObject{
|
|
Entity: msgraph.Entity{
|
|
ID: &u.Id.OpaqueId,
|
|
Object: msgraph.Object{
|
|
AdditionalData: map[string]interface{}{
|
|
"uidnumber": u.UidNumber,
|
|
"gidnumber": u.GidNumber,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|